Index: /trunk/tools/stsci_disks/p1_clear.pl
===================================================================
--- /trunk/tools/stsci_disks/p1_clear.pl	(revision 38360)
+++ /trunk/tools/stsci_disks/p1_clear.pl	(revision 38361)
@@ -70,5 +70,5 @@
 
 my $time = time();
-my $logDest = "neb://any/stsci_shuffle/${host}.${volume}/${dir}.${time}";
+my $logDest = "neb://any/stsci_shuffle/${host}.${volume}/${dir}.log.${time}";
 my $ipprc = PS::IPP::Config->new( "GPC1" ) or die "Could not create config object.\n";
 $ipprc->redirect_output($logDest) or die "Could not redirect output to logfile ${logDest}\n";
@@ -77,4 +77,5 @@
 my $root = "/data/${host}.${volume}/nebulous/${dir}";
 my @subdirectories = <$root/*>;
+my $md5_fails = 0;
 
 #print "/data/${host}.${volume}/nebulous/${dir}/*\n";
@@ -130,4 +131,12 @@
 		$vols[$i] = $vols[$i] . ".0";
 	    }
+	    
+	    # Check that we actually have a key on the host we're checking.
+	    my $local_uris = $neb->find_instances($keys[$i],"~" . $host . "." . $volume);
+	    if ($#{ $local_uris } == -1) { 
+		$vols[$i] = undef();
+		print "# No registered copy of $keys[$i] on ${host}.${volume}.  Treating as NOVOL\n";
+#		die "No local copy of $keys[$i] on $host . $volume\n";
+	    }
 	}
 	elsif ($belongs[$i] == 1) {
@@ -161,7 +170,7 @@
 		system("cp -a $files[$i] ${unknown_dir}/$keys[$i]");
 	    }
-	    system("sync") == 0 or die "Couldn't sync?";
-	}
-    }
+	}
+    }
+    system("sync") == 0 or die "Couldn't sync?";
     $otime = $time;
     $time = time();
@@ -174,4 +183,5 @@
 	if ($belongs[$i] == 0) {
 	    if (defined($vols[$i])) {
+		print "$keys[$i] $vols[$i] $host $volume \n";
 		my $uris = $neb->find_instances($keys[$i],$vols[$i]);
 		@$uris = map {URI->new($_)->file if $_} @$uris;
@@ -184,9 +194,18 @@
 	    my $tmpmd5 = local_md5sum($uri);
 	    if ($tmpmd5 ne $md5sums[$i]) { 
-		die "Post-replication md5sum does not match! $tmpmd5 != $md5sums[$i]";
+		if (defined($vols[$i])) {
+		    print "MD5SUM FAIL: $keys[$i] $vols[$i] $md5sums[$i] found: $tmpmd5 \n";
+		}
+		else {
+		    print "MD5SUM FAIL: $keys[$i] NOVOL_BECAUSE_UNKNOWN $md5sums[$i] found: $tmpmd5 \n";
+		}
+		$md5_fails ++;
+		next;
+#		die "Post-replication md5sum does not match! $keys[$i]: $vols[$i] $tmpmd5 != $md5sums[$i]";
 	    }
 	    # End my best validation thought.	    
 
 	    if (defined($vols[$i])) {
+#		print "HERE: $keys[$i] $host $volume\n";
 		$neb->cull($keys[$i],$host . "." . $volume);
 	    }
@@ -200,6 +219,6 @@
     $time = time();
     $dtime = $time - $otime;
-    print "LOG END $subdir $time $dtime\n";
-    die;
+    print "LOG END $subdir $time $dtime $md5_fails\n";
+#    die;
 }
 
