]> source.dussan.org Git - archiva.git/commitdiff
maven indexer cleanup only directory content so cleanup manually directory too
authorOlivier Lamy <olamy@apache.org>
Sun, 6 Nov 2011 13:50:40 +0000 (13:50 +0000)
committerOlivier Lamy <olamy@apache.org>
Sun, 6 Nov 2011 13:50:40 +0000 (13:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1198370 13f79535-47bb-0310-9956-ffa450edef68

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

index 674f261fb85a84c6f70d1410aeaccc041413a55a..045d2c28d66b5220e66ee8ce529ba9971d8d945d 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
+import org.apache.commons.io.FileUtils;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
@@ -130,6 +131,12 @@ public class DefaultIndexMerger
             {
                 indexer.removeIndexingContext( indexingContext, true );
             }
+            File directory = temporaryGroupIndex.getDirectory();
+            if ( directory != null && directory.exists() )
+            {
+                FileUtils.deleteDirectory( directory );
+            }
+            temporaryGroupIndexes.remove( temporaryGroupIndex );
         }
         catch ( IOException e )
         {
index 0845db6b1afc9aa8f461509672f19363069a72b2..3ee8b9e4a1f17a2395ad196cf6cf9e5ddbdf60d8 100644 (file)
@@ -21,14 +21,12 @@ package org.apache.archiva.indexer.merger;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
 import org.apache.maven.index.NexusIndexer;
-import org.apache.maven.index.context.IndexingContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import javax.inject.Inject;
-import java.io.IOException;
 import java.util.Date;
 
 /**
@@ -61,24 +59,8 @@ public class TemporaryGroupIndexCleaner
             // cleanup files older than 60 minutes 3600000
             if ( new Date().getTime() - temporaryGroupIndex.getCreationTime() > 3600000 )
             {
-                try
-                {
-                    IndexingContext context = indexer.getIndexingContexts().get( temporaryGroupIndex.getIndexId() );
-                    if ( context != null )
-                    {
-                        indexer.removeIndexingContext( context, true );
-                    }
-                    else
-                    {
-                        indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
-                    }
-                    indexMerger.getTemporaryGroupIndexes().remove( temporaryGroupIndex );
-                    log.debug( "remove directory {}", temporaryGroupIndex.getDirectory() );
-                }
-                catch ( IOException e )
-                {
-                    log.warn( "failed to remove directory:" + temporaryGroupIndex.getDirectory(), e );
-                }
+                indexMerger.cleanTemporaryGroupIndex( temporaryGroupIndex );
+
             }
         }
     }