PR: MNG-447

ensure the checksums don't get overwritten by the extra put commands


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@180072 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-06-05 05:54:48 +00:00
parent 00644fbd38
commit 075932b36d
1 changed files with 12 additions and 4 deletions

View File

@ -136,7 +136,8 @@ public class DefaultWagonManager
wagon.addTransferListener( downloadMonitor ); wagon.addTransferListener( downloadMonitor );
} }
Map checksums = new HashMap(); Map checksums = new HashMap( 2 );
Map sums = new HashMap( 2 );
// TODO: configure these on the repository // TODO: configure these on the repository
try try
@ -161,16 +162,23 @@ public class DefaultWagonManager
wagon.removeTransferListener( downloadMonitor ); wagon.removeTransferListener( downloadMonitor );
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself // Pre-store the checksums as any future puts will overwrite them
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); ) for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
{ {
String extension = (String) i.next(); String extension = (String) i.next();
ChecksumObserver observer = (ChecksumObserver) checksums.get( extension ); ChecksumObserver observer = (ChecksumObserver) checksums.get( extension );
sums.put( extension, observer.getActualChecksum() );
}
// We do this in here so we can checksum the artifact metadata too, otherwise it could be metadata itself
for ( Iterator i = checksums.keySet().iterator(); i.hasNext(); )
{
String extension = (String) i.next();
// TODO: shouldn't need a file intermediatary - improve wagon to take a stream // TODO: shouldn't need a file intermediatary - improve wagon to take a stream
File temp = File.createTempFile( "maven-artifact", null ); File temp = File.createTempFile( "maven-artifact", null );
temp.deleteOnExit(); temp.deleteOnExit();
FileUtils.fileWrite( temp.getAbsolutePath(), observer.getActualChecksum() ); FileUtils.fileWrite( temp.getAbsolutePath(), (String) sums.get( extension ) );
wagon.put( temp, remotePath + "." + extension ); wagon.put( temp, remotePath + "." + extension );
} }