Index: other-projects/nightly-tasks/snapshot/trunk/lib.pl
===================================================================
--- other-projects/nightly-tasks/snapshot/trunk/lib.pl	(revision 21773)
+++ other-projects/nightly-tasks/snapshot/trunk/lib.pl	(revision 21774)
@@ -93,6 +93,12 @@
 
 	if ( ! -d "$release_dir/products" ) {
-		die "error: products directory doesn't exist, exiting\n";
+		die "error: products directory doesn't exist, exiting. (Well, not that exciting, a bit of a downer really...)";
 	}
+
+	#copy products to a temporary folder, giving them their new names
+        if ( ! -d "$release_dir/uploads" ) {
+		system( "rm -rf '$release_dir/uploads'" );
+	}
+	mkdir "$release_dir/uploads";
 
 	@files = <$release_dir/products/*>;
@@ -100,26 +106,17 @@
 	for my $file ( @files ) {
 		my $filename = basename($file);
-		if ( !$only_upload || $filename =~ $only_upload ) {
+		#munge
+		for my $m ( @munges ) {
+			$doit="\$filename =~ $m"; eval "$doit";
+		}
 
-			#munge
-			for my $m ( @munges ) {
-				$doit="\$filename =~ $m"; eval "$doit";
-			}
-
-			#upload
-			print "Uploading '" . basename($file) . "' to '$filename'\n";
-			my $command = "scp";
-			if ( $^O eq "MSWin32" ) {
-				$command = "pscp";
-			}
-			if ( exists $ENV{'UPLOAD_IDENTITY_FILE'} ) {
-				$command .= " -i \"$ENV{'UPLOAD_IDENTITY_FILE'}\"";
-			}
-			$command .= " \"$file\" \"$ENV{'UPLOAD_DIR'}/$filename\"";
-			system($command);
-
-		} else {
-			print "Skipping upload of '$filename'\n";
-		}
+		#upload
+		print "Will upload '" . basename($file) . "' to '$filename'\n";
+		system( "cp '$file' '$release_dir/uploads/$filename'" );
 	}
+	my $command = "cd $release_dir/uploads && tar -cz * | ";
+	$command .= ($^O eq "MSWin32" ? "putty" : "ssh");
+	$command .= " -i '$ENV{'IDENTITY_FILE'}' nzdl\@puka.cs.waikato.ac.nz";
+	#system("$command");
+	print "$command\n";
 }
Index: other-projects/nightly-tasks/snapshot/trunk/task.pl
===================================================================
--- other-projects/nightly-tasks/snapshot/trunk/task.pl	(revision 21773)
+++ other-projects/nightly-tasks/snapshot/trunk/task.pl	(revision 21774)
@@ -27,4 +27,9 @@
 if ( ! exists $ENV{'DATA_DIR'} ) {
 	$ENV{'DATA_DIR'} = "$ENV{'HOME'}/snapshots";
+}
+
+#default identity dir
+if ( ! exists $ENV{'IDENTITY_DIR'} ) {
+	$ENV{'IDENTITY_DIR'} = "$ENV{'HOME'}/.ssh";
 }
 
@@ -59,5 +64,5 @@
 #setup based on mode
 if ( $ENV{'TASK_NAME'} =~ "caveat\$" ) {
-	$ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/caveat-emptor";
+	$ENV{'SNAPSHOT_MODE'} = "caveat";
 
 	if ( $major_version == 2 ) {
@@ -76,36 +81,34 @@
 	$ENV{'SERVER_EXE_LOCATION'} = "http://www.greenstone.org/caveat-emptor/server-$ENV{'snapshot_id2'}-candidate-" . get_date() . ".exe";
 
-} else {
-	if ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
-		$ENV{'BRANCH_PATH'}="tags/stable";
+} elsif ( $ENV{'TASK_NAME'} =~ "stable\$" ) {
+	$ENV{'SNAPSHOT_MODE'} = "stable";
+	$ENV{'BRANCH_PATH'} = "tags/stable";
 
-		#dont proceed if main/stable is old
-		#get last changed date from svn
-		open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
-			or die "Cant determine age of stable tag";
-		my $changed_date;
-		while ( my $line = <INFO>) {
-			chomp($line);
-			if ( $line =~ /^Last Changed Date:/ ) {
-				$changed_date = $line;
-				break;
-			}
-		}
-		close(INFO);
-		#change the format
-		$changed_date =~ s/.*: ([^ ]+) .*/\1/g;
-		if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
-			die "Cant determine age of stable tag";
-		}
-		$changed_date =~ s/-/./g;
-		#check if main/stable is new
-		if ( $changed_date ne get_date() ) {
-			print "main/stable is old, will not create snapshot\n";
-			exit;
-		} else {
-			print "main/stable is fresh, will create snapshot\n";
+	#dont proceed if main/stable is old
+	#get last changed date from svn
+	open( INFO, "svn info http://svn.greenstone.org/main/$ENV{'BRANCH_PATH'}|" )
+		or die "Cant determine age of stable tag";
+	my $changed_date;
+	while ( my $line = <INFO>) {
+		chomp($line);
+		if ( $line =~ /^Last Changed Date:/ ) {
+			$changed_date = $line;
+			break;
 		}
 	}
-	$ENV{'UPLOAD_DIR'}="nzdl\@puka.cs.waikato.ac.nz:/greenstone/greenstone.org/base/release-snapshots";
+	close(INFO);
+	#change the format
+	$changed_date =~ s/.*: ([^ ]+) .*/\1/g;
+	if ( $changed_date !~ /^20[0-9]{2}-[0-9]{2}-[0-9]{2}$/ ) {
+		die "Cant determine age of stable tag";
+	}
+	$changed_date =~ s/-/./g;
+	#check if main/stable is new
+	if ( $changed_date ne get_date() ) {
+		print "main/stable is old, will not create snapshot\n";
+		exit;
+	} else {
+		print "main/stable is fresh, will create snapshot\n";
+	}
 
 	#set the path to server.exe
@@ -113,8 +116,11 @@
 }
 
+#use the  correct key for uploading
+$ENV{'IDENTITY_FILE'} =
+	"$ENV{'IDENTITY_DIR'}/upload-" . $ENV{'SNAPSHOT_MODE'} . ($^O eq "MSWin32" ? ".ppk" : "");
+
+
 #always rename the log not to clash with other files on puka
 $ENV{'munges'} = $ENV{'munges'} . " s/\.out/-" . get_date() . "-log.txt/";
-
-
 
 #choose a snapshot ID
