Skip to content

Commit 158d01d

Browse files
authored
Fixing removing incorectly detected iml file (#7726)
1 parent ecc18ea commit 158d01d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

base/src/com/google/idea/blaze/base/sync/projectstructure/ModuleEditorImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public Module createModule(String moduleName, ModuleType<?> moduleType) {
7777
Module module = moduleModel.findModuleByName(moduleName);
7878
if (module == null) {
7979
File imlFile = new File(imlDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
80-
removeImlFile(imlFile);
80+
VirtualFile virtualImlFile = VfsUtil.findFileByIoFile(imlFile, true);
81+
removeImlFile(virtualImlFile);
8182
module = moduleModel.newModule(imlFile.getPath(), moduleType.getId());
8283
module.setOption(EXTERNAL_SYSTEM_ID_KEY, EXTERNAL_SYSTEM_ID_VALUE);
8384
}
@@ -122,7 +123,7 @@ public void commitWithGc(BlazeContext context) {
122123
continue;
123124
}
124125
moduleModel.disposeModule(module);
125-
File imlFile = new File(module.getModuleFilePath());
126+
VirtualFile imlFile = module.getModuleFile();
126127
removeImlFile(imlFile);
127128
}
128129
}
@@ -145,9 +146,8 @@ private File getImlDirectory(BlazeImportSettings importSettings) {
145146
// Otherwise, it is possible for IntelliJ to read the
146147
// old IML file from its index and behave unpredictably
147148
// (like failing to save the new IML files to disk).
148-
private static void removeImlFile(final File imlFile) {
149-
final VirtualFile imlVirtualFile = VfsUtil.findFileByIoFile(imlFile, true);
150-
if (imlVirtualFile != null && imlVirtualFile.exists()) {
149+
private static void removeImlFile(final VirtualFile imlVirtualFile) {
150+
if (imlVirtualFile != null && imlVirtualFile.exists() && !imlVirtualFile.isDirectory()) {
151151
ApplicationManager.getApplication()
152152
.runWriteAction(
153153
new Runnable() {

0 commit comments

Comments
 (0)