this is mostly revert of my last year commit 101e4e4 from 27.03.13 because the change... appcode/134.1016 cppide/134.1019 idea/134.1020
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Fri, 7 Feb 2014 21:48:29 +0000 (22:48 +0100)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Fri, 7 Feb 2014 21:48:29 +0000 (22:48 +0100)
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java

index 048c7599408bea52cd83165d4c09481b36c19651..fa81167018462df17f488d2dbccf4b3af0c4c948 100644 (file)
@@ -1322,20 +1322,21 @@ public class FileBasedIndexImpl extends FileBasedIndex {
     if (status.compareAndSet(REQUIRES_REBUILD, REBUILD_IN_PROGRESS)) {
       cleanupProcessedFlag();
 
-      try {
-        clearIndex(indexId);
-      } catch (StorageException ex) {
-        requestRebuild(indexId, new Throwable(ex));
-      }
-
+      advanceIndexVersion(indexId);
+      
       final Runnable rebuildRunnable = new Runnable() {
         @Override
         public void run() {
           try {
+            doClearIndex(indexId);
             if (!cleanupOnly) {
               scheduleIndexRebuild(false);
             }
           }
+          catch (StorageException e) {
+            requestRebuild(indexId);
+            LOG.info(e);
+          }
           finally {
             status.compareAndSet(REBUILD_IN_PROGRESS, OK);
           }
@@ -1381,9 +1382,17 @@ public class FileBasedIndexImpl extends FileBasedIndex {
   }
 
   private void clearIndex(@NotNull final ID<?, ?> indexId) throws StorageException {
+    advanceIndexVersion(indexId);
+    doClearIndex(indexId);
+  }
+
+  private void doClearIndex(ID<?, ?> indexId) throws StorageException {
     final UpdatableIndex<?, ?, FileContent> index = getIndex(indexId);
     assert index != null : "Index with key " + indexId + " not found or not registered properly";
     index.clear();
+  }
+
+  private void advanceIndexVersion(ID<?, ?> indexId) {
     try {
       IndexInfrastructure.rewriteVersion(IndexInfrastructure.getVersionFile(indexId), myIndexIdToVersionMap.get(indexId));
     }