From: Olivier Lamy Date: Sun, 6 Nov 2011 13:50:40 +0000 (+0000) Subject: maven indexer cleanup only directory content so cleanup manually directory too X-Git-Tag: archiva-1.4-M2~139 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7738486c1a1f464cff20f1f1f3c496421d549fad;p=archiva.git maven indexer cleanup only directory content so cleanup manually directory too git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1198370 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java index 674f261fb..045d2c28d 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultIndexMerger.java @@ -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 ) { diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java index 0845db6b1..3ee8b9e4a 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java @@ -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 ); + } } }