platform: check corruption marker before any other index activities idea/140.2000
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 28 Jan 2015 10:22:37 +0000 (13:22 +0300)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Wed, 28 Jan 2015 10:23:52 +0000 (13:23 +0300)
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java

index b24502ceab12ea7943b1bd9a920c9e793d02b1be..7fddfc1022c8b0d99e1b0ada815e34570316d2bf 100644 (file)
@@ -266,6 +266,14 @@ public class FileBasedIndexImpl extends FileBasedIndex {
 
   private void initExtensions() {
     try {
+      File indexRoot = PathManager.getIndexRoot();
+      final File corruptionMarker = new File(indexRoot, CORRUPTION_MARKER_NAME);
+      final boolean currentVersionCorrupted = corruptionMarker.exists();
+      if (currentVersionCorrupted) {
+        FileUtil.deleteWithRenaming(indexRoot);
+        indexRoot.mkdirs();
+      }
+
       FileBasedIndexExtension[] extensions = Extensions.getExtensions(FileBasedIndexExtension.EXTENSION_POINT_NAME);
 
       boolean versionChanged = false;
@@ -282,14 +290,6 @@ public class FileBasedIndexImpl extends FileBasedIndex {
         }
       }
 
-      File indexRoot = PathManager.getIndexRoot();
-      final File corruptionMarker = new File(indexRoot, CORRUPTION_MARKER_NAME);
-      final boolean currentVersionCorrupted = corruptionMarker.exists();
-      if (currentVersionCorrupted) {
-        FileUtil.deleteWithRenaming(indexRoot);
-        indexRoot.mkdirs();
-      }
-
       for (List<ID<?, ?>> value : myFileType2IndicesWithFileTypeInfoMap.values()) {
         value.addAll(myIndicesWithoutFileTypeInfo);
       }
@@ -373,8 +373,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
   /**
    * @return true if registered index requires full rebuild for some reason, e.g. is just created or corrupted
    */
-  private <K, V> boolean registerIndexer(@NotNull final FileBasedIndexExtension<K, V> extension)
-    throws IOException {
+  private <K, V> boolean registerIndexer(@NotNull final FileBasedIndexExtension<K, V> extension) throws IOException {
     final ID<K, V> name = extension.getName();
     final int version = extension.getVersion();
     final File versionFile = IndexInfrastructure.getVersionFile(name);