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;
{
indexer.removeIndexingContext( indexingContext, true );
}
+ File directory = temporaryGroupIndex.getDirectory();
+ if ( directory != null && directory.exists() )
+ {
+ FileUtils.deleteDirectory( directory );
+ }
+ temporaryGroupIndexes.remove( temporaryGroupIndex );
}
catch ( IOException e )
{
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;
/**
// 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 );
+
}
}
}