mirror of https://github.com/apache/maven.git
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. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@354631 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7458db31f5
commit
4097d7ae0f
|
@ -375,7 +375,7 @@ public class DefaultWagonManager
|
|||
// 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 @@ public class DefaultWagonManager
|
|||
// 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 @@ public class DefaultWagonManager
|
|||
// 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 @@ public class DefaultWagonManager
|
|||
// 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 @@ public class DefaultWagonManager
|
|||
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 + "'" );
|
||||
|
|
Loading…
Reference in New Issue