maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r354631 - /maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Date Wed, 07 Dec 2005 00:26:14 GMT
Author: jdcasey
Date: Tue Dec  6 16:26:09 2005
New Revision: 354631

URL: http://svn.apache.org/viewcvs?rev=354631&view=rev
Log:
PR: MNG-1550
Submitted By: Edwin Punzalan
Reviewed By: John Casey

Applied patch, with small change. This patch will save the checksums in the local repo, once
they've transferred safely. The change I made was to pass in the "real" destination to the
verifyChecksum method, rather than only the temp destination. This will allow the checksums
to actually persist in the local repo, rather than a temporary directory.


Modified:
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=354631&r1=354630&r2=354631&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Tue Dec  6 16:26:09 2005
@@ -375,7 +375,7 @@
                 // try to verify the SHA-1 checksum for this file.
                 try
                 {
-                    verifyChecksum( sha1ChecksumObserver, temp, remotePath, ".sha1", wagon
);
+                    verifyChecksum( sha1ChecksumObserver, destination, temp, remotePath,
".sha1", wagon );
                 }
                 catch ( ChecksumFailedException e )
                 {
@@ -401,7 +401,7 @@
                     // file...we'll try again with the MD5 checksum.
                     try
                     {
-                        verifyChecksum( md5ChecksumObserver, temp, remotePath, ".md5", wagon
);
+                        verifyChecksum( md5ChecksumObserver, destination, temp, remotePath,
".md5", wagon );
                     }
                     catch ( ChecksumFailedException e )
                     {
@@ -504,7 +504,7 @@
         // otherwise it is ignore
     }
 
-    private void verifyChecksum( ChecksumObserver checksumObserver, File destination, String
remotePath,
+    private void verifyChecksum( ChecksumObserver checksumObserver, File destination, File
tempDestination, String remotePath,
                                  String checksumFileExtension, Wagon wagon )
         throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
     {
@@ -513,11 +513,11 @@
             // grab it first, because it's about to change...
             String actualChecksum = checksumObserver.getActualChecksum();
 
-            File checksumFile = new File( destination + checksumFileExtension );
-            checksumFile.deleteOnExit();
-            wagon.get( remotePath + checksumFileExtension, checksumFile );
+            File tempChecksumFile = new File( tempDestination + checksumFileExtension + ".tmp"
);
+            tempChecksumFile.deleteOnExit();
+            wagon.get( remotePath + checksumFileExtension, tempChecksumFile );
 
-            String expectedChecksum = FileUtils.fileRead( checksumFile );
+            String expectedChecksum = FileUtils.fileRead( tempChecksumFile );
 
             // remove whitespaces at the end
             expectedChecksum = expectedChecksum.trim();
@@ -538,7 +538,13 @@
                     expectedChecksum = expectedChecksum.substring( 0, spacePos );
                 }
             }
-            if ( !expectedChecksum.equals( actualChecksum ) )
+            if ( expectedChecksum.equals( actualChecksum ) )
+            {
+                File checksumFile = new File( destination + checksumFileExtension );
+                if ( checksumFile.exists() ) checksumFile.delete();
+                FileUtils.copyFile( tempChecksumFile, checksumFile );
+            }
+            else
             {
                 throw new ChecksumFailedException( "Checksum failed on download: local =
'" + actualChecksum +
                     "'; remote = '" + expectedChecksum + "'" );



Mime
View raw message