Index: other-projects/nightly-tasks/diffcol/trunk/task.pl
===================================================================
--- other-projects/nightly-tasks/diffcol/trunk/task.pl	(revision 27678)
+++ other-projects/nightly-tasks/diffcol/trunk/task.pl	(revision 27687)
@@ -35,4 +35,5 @@
 #my $script_ext = $isWin ? ".bat" : ".bash";
 my $setup_script = "setup"; # needs to become gs3-setup for GS3
+my $use_blat = 0; # if we ever get blat to send mail/attachments on Windows working, set this to 1
 
 # TASK_HOME should be the toplevel diffcol folder
@@ -45,11 +46,12 @@
 
 # we'll be using BLAT to send mail attachments on Windows
-my $blat = &filename_concat($ENV{'BIN_DIR'}, "blat", "full", "blat.exe");
-if($isWin && ! -e $blat) {
-	print STDERR "*** No blat.exe found in $blat.\n";
-	print STDERR "*** Blat needed to send mail with attachments on Windows.\n";
-	print STDERR "*** Extract the blat zip file found in $ENV{'BIN_DIR'}\n";
-	print STDERR "*** for your bit architecture and name the folder 'blat'\n";
-	
+my $blat = $use_blat ? &filename_concat($ENV{'BIN_DIR'}, "blat", "full", "blat.exe") : 0;
+if($isWin && $use_blat && ! -e $blat) {	
+	print STDERR "\n***********************************\n";
+	print STDERR "No blat.exe found in $blat.\n";
+	print STDERR "Blat needed to send mail with attachments on Windows.\n";
+	print STDERR "Extract the blat zip file found in $ENV{'BIN_DIR'}\n";
+	print STDERR "for your bit architecture and name the folder 'blat'\n";
+	print STDERR "***********************************\n\n";
 	$blat = 0;
 }
@@ -390,5 +392,5 @@
 	print STDERR "$collection - Importing:\n";
 	print $xml_fh "<import>\n";
-	&run_build_script("import.pl -OIDtype hash_on_full_filename $collection -removeold");
+	&run_build_script("import.pl $collection -removeold"); #-OIDtype hash_on_full_filename
 	print $xml_fh "</import>\n";
 	print STDERR "done\n";	
@@ -450,6 +452,5 @@
 
 #    chdir($greenstone_home);
-
-    # we are in $greenstone_home, can directly run the build cmd on the collection
+    # we are in $greenstone_home already, can directly run the build cmd on the collection
     if(!$isWin) {
 	$cmd = "bash -c \"export GSDLHOME=&& source $setup_script.bash && $cmd\"";
@@ -457,7 +458,6 @@
     } else { # Need to prefix cmd -c/-k as necessary
 	$cmd = "cmd /c \"set GSDLHOME=&& $setup_script.bat && perl -S $cmd\"";
-##	print STDERR "@@@@ Going to call command: $cmd\n";
-	
-    }
+    }
+##     print STDERR "@@@@ Going to call command: $cmd\n";
 
     return system($cmd);
@@ -565,8 +565,18 @@
     opendir my($dh), $ENV{'DATA_DIR'} or die "Could not open DATA_DIR: $!";
     for my $entry (readdir $dh) {
-	next if ($entry !~ m/(\.xml|\.html)$/);
-	# get the absolute path to the files before copying them over
-	$entry = &filename_concat($ENV{'DATA_DIR'}, $entry);
-	copy($entry, $ENV{'UPLOAD_DIR'});
+	next if ($entry !~ m/(\.xml|\.html?)$/);
+
+	# copy the reports across with different names: with OS prefixed to them. And for the HTML file on Win, rename to HTM
+	# html files uploaded from windows to nzdl are empty for no reason. Uploading as htm seems to work
+	my $os = $^O;
+	(my $os_entry = $entry) =~ s@\.html$@.htm@ if $isWin;
+	$os_entry = $^O."-$os_entry";	
+	
+	# get the absolute path to the original files before copying them over
+	$entry = &filename_concat($ENV{'DATA_DIR'}, $entry);		
+
+	# copy them over with their new names
+##	print STDERR "@@@@ copying across $entry to $ENV{'UPLOAD_DIR'} as $os_entry\n";
+	copy($entry, "$ENV{'UPLOAD_DIR'}$sep$os_entry"); #copy($entry, "$ENV{'UPLOAD_DIR'}");
     }
     closedir $dh;
@@ -588,5 +598,5 @@
 	
 	# the report we want to upload is actually just report-$dateid.html
-	my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.html | "; #&& cat *.html | "; # && tar -c * |
+	my $command = "cd \"$ENV{'UPLOAD_DIR'}\" && tar -c *.htm* | "; #&& cat *.html | "; # && tar -c * |
 	$command .= ($^O eq "MSWin32" ? "plink" : "ssh");
 	$command .= " -T -i \"$ENV{'IDENTITY_FILE'}\" nzdl\@puka.cs.waikato.ac.nz";
@@ -621,6 +631,6 @@
 	my $attach_file = &filename_concat($ENV{'DATA_DIR'}, "report-$dateid.html");
 
-	if($isWin) {
-		if($blat && $ENV{'GSDL_SMTP'}) {
+	if($isWin) {	
+		if($use_blat && $blat && $ENV{'GSDL_SMTP'}) {
 			# http://stackoverflow.com/questions/709635/sending-mail-from-batch-file
 			#blat -to user@example.com -server smtp.example.com -f batch_script@example.com -subject "subject" -body "body"
@@ -631,7 +641,11 @@
 		}
 		else {
-			$result = 0;
+			$result = 1; # status from running mail command is 0 if success, 1 if fail
 			print STDERR "********************************************\n";
-			print STDERR "Need blat and SMTP set to send mail attachment\n";
+			if ($use_blat) {
+				print STDERR "Need blat and SMTP set to send mail attachment\n" ;
+			} else {	
+				print STDERR "Not set up to send mail on Windows\n";
+			}
 			print STDERR "Inspect report at: $attach_file\n";
 			print STDERR "********************************************\n";
