]> source.dussan.org Git - archiva.git/commitdiff
ensure we correctly delete temporary download directory
authorOlivier Lamy <olamy@apache.org>
Sat, 1 Oct 2011 14:21:14 +0000 (14:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 1 Oct 2011 14:21:14 +0000 (14:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177991 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java

index b334449f5ffd2d3ccc3079f542e4bc5105e54cf8..021b55a2331a6a02b4acd7c789b4de8fce8c268b 100644 (file)
@@ -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( );