From 075932b36df523ad207400738c3769036c7f737c Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Sun, 5 Jun 2005 05:54:48 +0000 Subject: [PATCH] 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 --- .../artifact/manager/DefaultWagonManager.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java index b6cc834965..96ba82c146 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java @@ -136,7 +136,8 @@ public class DefaultWagonManager wagon.addTransferListener( downloadMonitor ); } - Map checksums = new HashMap(); + Map checksums = new HashMap( 2 ); + Map sums = new HashMap( 2 ); // TODO: configure these on the repository try @@ -161,16 +162,23 @@ public class DefaultWagonManager 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(); ) { String extension = (String) i.next(); 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 File temp = File.createTempFile( "maven-artifact", null ); temp.deleteOnExit(); - FileUtils.fileWrite( temp.getAbsolutePath(), observer.getActualChecksum() ); + FileUtils.fileWrite( temp.getAbsolutePath(), (String) sums.get( extension ) ); wagon.put( temp, remotePath + "." + extension ); } @@ -499,4 +507,4 @@ public class DefaultWagonManager mirrors.put( mirrorOf, mirror ); } -} \ No newline at end of file +}