Fixing MNG-797: "fix checksum parsing"

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@265787 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Trygve Laugstol 2005-09-01 21:53:54 +00:00
parent 4bfe2cc1ab
commit 6cf731be0e

View File

@ -483,6 +483,26 @@ private void verifyChecksum( ChecksumObserver checksumObserver, File destination
wagon.get( remotePath + checksumFileExtension, checksumFile );
String expectedChecksum = FileUtils.fileRead( checksumFile );
// remove whitespaces at the end
expectedChecksum = expectedChecksum.trim();
// check for 'MD5 (name) = CHECKSUM'
if ( expectedChecksum.startsWith( "MD5" ) )
{
int lastSpacePos = expectedChecksum.lastIndexOf( ' ' );
expectedChecksum = expectedChecksum.substring( lastSpacePos + 1 );
}
else
{
// remove everything after the first space (if available)
int spacePos = expectedChecksum.indexOf( ' ' );
if ( spacePos != -1 )
{
expectedChecksum = expectedChecksum.substring( 0, spacePos );
}
}
if ( !expectedChecksum.equals( actualChecksum ) )
{
throw new ChecksumFailedException( "Checksum failed on download: local = '" + actualChecksum +