Index: trunk/ippScripts/scripts/rawcheck.pl
===================================================================
--- trunk/ippScripts/scripts/rawcheck.pl	(revision 36679)
+++ trunk/ippScripts/scripts/rawcheck.pl	(revision 36684)
@@ -134,8 +134,4 @@
 	    $existing_copies++;
 	    $md5sums[$i] = local_md5sum($files[$i]);
-#	    my $fh;
-#	    open($fh,$files[$i]);
-#	    $md5sums[$i] = Digest::MD5->new->addfile($fh)->hexdigest;
-#	    close($fh);
 	    $md5sum_uniq{$md5sums[$i]} = 1;
 
@@ -184,9 +180,6 @@
 	    "object id:             ", @$stat[0], "\n",
 	    "key:                   ", @$stat[1], "\n",
-	    "read lock:             ", @$stat[2], "\n";
-#	    "write lock:            ", @$stat[3], "\n";
 	print 
-	    "epoch:                 ", @$stat[4], "\n",
-	    "mtime:                 ", @$stat[5], "\n";
+	"epoch:                 ", @$stat[4], "\n";
 	print 
 	    "md5sum count:          ", scalar(keys %md5sum_uniq), "\n";
@@ -220,21 +213,41 @@
 	}
 	close(DD);
-	$quality[0] = 1;
-	print "cp $good_file $files[0]\n";
-	system("cp $good_file $files[0]");
-# Begin my best validation thought
+	if ($good_file eq '') {
+	    die "No valid instance of key: $key";
+	}
+	else {
+	    $quality[0] = 1;
+	    print "cp $good_file $files[0]\n";
+	    system("cp $good_file $files[0]");
+	}
+        # Begin my best validation thought
 	{
 	    my $tmpmd5 = local_md5sum($files[0]);
-# 	    my $fh;
-# 	    open($fh,$files[0]);
-# 	    my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
-# 	    close($fh);
 	    if ($tmpmd5 ne $md5sum) { 
 		die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
 	    }
 	}
-# End my best validation thought.
+        # End my best validation thought.
 
 	$Ngood = 1;  # We now hand off this single valid instance object to be handled by the Ngood=1 case.
+    }
+    
+    if ($quality[0] == 0) { # The first instance is bad.
+	# But since we're here, and not up there, there must be at least one good copy.  Find it.
+	for (my $i = 0; $i <= $#md5sums; $i++) {
+	    if ($md5sums[$i] eq $md5sum) { # Found it.
+		print "cp $files[$i] $files[0]\n";
+		system("cp $files[$i] $files[0]");
+                # Begin my best validation thought
+		{
+		    my $tmpmd5 = local_md5sum($files[0]);
+		    if ($tmpmd5 ne $md5sum) { 
+			die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
+		    }
+		}
+                # End my best validation thought.
+		last; # We're done here now.
+	    }
+	}	
     }
 
@@ -256,17 +269,13 @@
 		if ($@) { die $@; }
 		
-# Begin my best validation thought
+                # Begin my best validation thought
 		system("sync") == 0 or die "Couldn't sync?";
 		my $uris = $neb->find_instances($key,$rep_vol);
 		@$uris = map {URI->new($_)->file if $_} @$uris;
 		my $tmpmd5 = local_md5sum(${ $uris }[0]);
-# 		my $fh;
-# 		open($fh,${ $uris }[0]);
-# 		my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
-# 		close($fh);
 		if ($tmpmd5 ne $md5sum) { 
 		    die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
 		}
-# End my best validation thought.
+                # End my best validation thought.
 	    }	    
 	}
@@ -280,19 +289,13 @@
 		if ($@) { die $@; }
 
-# Begin my best validation thought
+                # Begin my best validation thought
 		system("sync") == 0 or die "Couldn't sync?";
 		my $uris = $neb->find_instances($key,$rep_vol);
 		@$uris = map {URI->new($_)->file if $_} @$uris;
-
-#		print $uris . " " . ${ $uris }[0] . " \n";
 		my $tmpmd5 = local_md5sum(${ $uris }[0]);
-# 		my $fh;
-# 		open($fh,${ $uris }[0]);
-# 		my $tmpmd5 = Digest::MD5->new->addfile($fh)->hexdigest;
-# 		close($fh);
 		if ($tmpmd5 ne $md5sum) { 
 		    die "Post-replication md5sum does not match! $tmpmd5 != $md5sum";
 		}
-# End my best validation thought.
+                # End my best validation thought.
 
 	    }	    
@@ -309,4 +312,7 @@
 #	    print "$existance[$i] $quality[$i] $md5sums[$i] $md5sum $diskhosts[$i] $diskvols[$i]\n";
 	    if ($quality[$i] != 1) {
+		if ($existance[$i] == 0) { # This disk file doesn't exist.
+		    system("touch $files[$i]");
+		}
 		my $cull_vol = $diskhosts[$i] . "." . $diskvols[$i];
 		print "neb-cull --volume $cull_vol $key\n";
@@ -314,5 +320,5 @@
 		    # The tilde here is to force hard volumes.  Don't touch it.
 		    $neb->cull($key,"~${cull_vol}",2) or die "failed to cull a superfluous instance";
-		    if ($@) { die $@; }
+		    if ($@) { die "$@"; }
 		}
 	    }
