]> source.dussan.org Git - archiva.git/commitdiff
remove temporary indexes from indexer too
authorOlivier Lamy <olamy@apache.org>
Fri, 4 Nov 2011 18:29:41 +0000 (18:29 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 4 Nov 2011 18:29:41 +0000 (18:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1197703 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java

index 1943e6cc7a54e86a4d1d3d4c697b1d29504d2952..9c061349030f6bf7876d6decc18c73d14648ca24 100644 (file)
@@ -104,7 +104,7 @@ public class DefaultIndexMerger
                 IndexPackingRequest request = new IndexPackingRequest( indexingContext, indexLocation );
                 indexPacker.packIndex( request );
             }
-            temporaryIndexes.add( new TemporaryIndex( tempRepoFile ) );
+            temporaryIndexes.add( new TemporaryIndex( tempRepoFile, tempRepoId ) );
             return indexingContext.getIndexDirectoryFile();
         }
         catch ( IOException e )
@@ -128,7 +128,15 @@ public class DefaultIndexMerger
             {
                 try
                 {
-                    FileUtils.deleteDirectory( temporaryIndex.directory );
+                    IndexingContext context = indexer.getIndexingContexts().get( temporaryIndex.indexId );
+                    if ( context != null )
+                    {
+                        indexer.removeIndexingContext( context, true );
+                    }
+                    else
+                    {
+                        FileUtils.deleteDirectory( temporaryIndex.directory );
+                    }
                     temporaryIndexes.remove( temporaryIndex );
                     log.debug( "remove directory {}", temporaryIndex.directory );
                 }
@@ -147,9 +155,12 @@ public class DefaultIndexMerger
 
         private File directory;
 
-        TemporaryIndex( File directory )
+        private String indexId;
+
+        TemporaryIndex( File directory, String indexId )
         {
             this.directory = directory;
+            this.indexId = indexId;
         }
 
         @Override