From 5ff3b3085610487761198a71ecd72ba6b5db20b9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sat, 1 Oct 2011 14:21:14 +0000 Subject: [PATCH] ensure we correctly delete temporary download directory git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177991 13f79535-47bb-0310-9956-ffa450edef68 --- .../scheduler/indexing/DownloadRemoteIndexTask.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java index b334449f5..021b55a23 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java @@ -116,6 +116,8 @@ public class DownloadRemoteIndexTask // create a temp directory to download files final File tempIndexDirectory = new File( indexingContext.getIndexDirectoryFile( ).getParent( ), ".tmpIndex" ); + File indexCacheDirectory = new File( indexingContext.getIndexDirectoryFile( ).getParent( ), ".indexCache" ); + indexCacheDirectory.mkdirs(); try { if ( tempIndexDirectory.exists( ) ) @@ -123,6 +125,7 @@ public class DownloadRemoteIndexTask FileUtils.deleteDirectory( tempIndexDirectory ); } tempIndexDirectory.mkdirs( ); + tempIndexDirectory.deleteOnExit(); String baseIndexUrl = indexingContext.getIndexUpdateUrl( ); final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl( ) ).getProtocol( ) ); @@ -174,14 +177,13 @@ public class DownloadRemoteIndexTask { try { - log.debug( "resourceFetcher#retrieve, name:{}", name ); - //TODO check those files are deleted !! + log.info( "index update retrieve file, name:{}", name ); File file = new File( tempIndexDirectory, name ); if ( file.exists( ) ) { file.delete( ); } - //file.deleteOnExit(); + file.deleteOnExit(); wagon.get( name, file ); return new FileInputStream( file ); } @@ -202,6 +204,7 @@ public class DownloadRemoteIndexTask IndexUpdateRequest request = new IndexUpdateRequest( indexingContext, resourceFetcher ); request.setForceFullUpdate( this.fullDownload ); + request.setLocalIndexCacheDir( indexCacheDirectory ); this.indexUpdater.fetchAndUpdateIndex( request ); stopWatch.stop( ); -- 2.39.5