Index: trunk/ippScripts/scripts/automate_stacks.pl
===================================================================
--- trunk/ippScripts/scripts/automate_stacks.pl	(revision 29266)
+++ trunk/ippScripts/scripts/automate_stacks.pl	(revision 29653)
@@ -1307,4 +1307,20 @@
 ################################################################################
 
+sub verify_uniqueness_diff {
+    my $warp_id_1 = shift;
+    my $warp_id_2 = shift;
+    my $date = shift;
+    my $target = shift;
+
+    my $db = init_gpc_db();
+    $date =~ s/-//g;
+    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target);
+
+    my $sth = "SELECT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2";
+    my $data_ref = $db->selectall_arrayref( $sth );
+
+    return($#{ $data_ref } + 1);
+}
+
 sub do_extra_processing {
     my $date = shift;
@@ -1332,5 +1348,5 @@
 	    if (($#{ $warps } + 1) % 2 != 0) {
 		print STDERR "Number of input warps to make OSS diffs is not even! $#{ $warps }\n";
-		die;
+		last;
 	    }
 	    
@@ -1341,4 +1357,12 @@
 		my $template_exp_id = ${ $template_warp }[0];
 		
+		my $input_warp_id = ${ $input_warp }[1];
+		my $template_warp_id = ${ $template_warp }[1];
+
+		if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) {
+		    print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id\n";
+		    next;
+		}
+
 		my $cmd = "$difftool -dbname $dbname  -definewarpwarp ";
 		$cmd .= "-input_label $label  -template_label $label ";
