Index: trunk/ippScripts/scripts/magic_destreak_revert.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 30693)
+++ trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 30754)
@@ -78,5 +78,15 @@
     defined $outroot;
 
-&my_die("bytes and md5sum are is required for raw stage stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'raw' and (!$bytes or !$md5sum));
+if (defined($replace) and ($replace eq "T")) {
+    $replace = 1;
+} else {
+    $replace = 0;
+}
+
+my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
+
+$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
+
+&my_die("bytes and md5sum are is required for raw stage stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($replace and $stage eq 'raw' and (!$bytes or !$md5sum));
 
 &my_die("cam_path_base is required for chip stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'chip' and !$cam_path_base);
@@ -84,7 +94,4 @@
 
 
-my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
-
-$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
 
 $cam_reduction = 'DEFAULT' if !defined $cam_reduction or ($cam_reduction eq "NULL");
@@ -118,10 +125,4 @@
 my $basename = basename($path_base);
 my $nebulousInput = inNebulous($dirname);
-
-if (defined($replace) and ($replace eq "T")) {
-    $replace = 1;
-} else {
-    $replace = 0;
-}
 
 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
@@ -370,4 +371,16 @@
     my $force = 1; # force deletion of backup files in nebulous
 
+    if (!$replace) {
+        # we don't need to do all of this checking unless the destreak run is
+        # replace mode just delete the backup 
+        my $error_code = $ipprc->kill_file($backup);
+        if ($error_code) {
+            print STDERR "failed to kill $backup: error_code $error_code\n";
+            return 0;
+        } else {
+            return 1;
+        }
+    }
+
     my $o_path = $ipprc->file_resolve($original);
     my $original_result;
