maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r902298 - /maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java
Date Fri, 22 Jan 2010 22:38:34 GMT
Author: olamy
Date: Fri Jan 22 22:38:34 2010
New Revision: 902298

URL: http://svn.apache.org/viewvc?rev=902298&view=rev
Log:
[MNG-4543] Cleanup tmp files created by DefaultWagonManager
Issue id: MNG-4543

Modified:
    maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java?rev=902298&r1=902297&r2=902298&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java
(original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/DefaultWagonManager.java
Fri Jan 22 22:38:34 2010
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -485,6 +486,8 @@
         {
             checksums.put( CHECKSUM_IDS[i], addChecksumObserver( wagon, CHECKSUM_ALGORITHMS[i]
) );
         }
+        
+        List<File> temporaryFiles = new ArrayList<File>();
 
         try
         {
@@ -517,6 +520,7 @@
                 temp.deleteOnExit();
                 FileUtils.fileWrite( temp.getAbsolutePath(), "UTF-8", sums.get( extension
) );
 
+                temporaryFiles.add( temp );
                 wagon.put( temp, remotePath + "." + extension );
             }
         }
@@ -542,6 +546,9 @@
         }
         finally
         {
+            // MNG-4543
+            cleanupTemporaryFiles( temporaryFiles );
+            
             // Remove every checksum listener
             for ( String aCHECKSUM_IDS : CHECKSUM_IDS )
             {
@@ -558,6 +565,24 @@
         }
     }
 
+    private void cleanupTemporaryFiles(List<File> files)
+    {
+        for ( File file : files )
+        {
+            // really don't care if it failed here only log warning
+            try
+            {
+                file.delete();
+            }
+            catch ( Exception e )
+            {
+                logger.warn( "skip failed to delete temporary file : " + file.getAbsolutePath()
+ " , message "
+                    + e.getMessage() );
+            }
+        }
+       
+    }
+    
     private ChecksumObserver addChecksumObserver( Wagon wagon, String algorithm )
         throws TransferFailedException
     {



Mime
View raw message