Index: trunk/ippScripts/scripts/magic_destreak_cleanup.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak_cleanup.pl	(revision 27240)
+++ trunk/ippScripts/scripts/magic_destreak_cleanup.pl	(revision 27256)
@@ -36,5 +36,5 @@
 
 # Parse the command-line arguments
-my ($magic_ds_id, $camera);
+my ($magic_ds_id, $camera, $force);
 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
 
@@ -42,4 +42,5 @@
            'magic_ds_id=s'  => \$magic_ds_id,# Magic destreak run identifier
            'camera=s'       => \$camera,     # camera for evaluating file rules
+           'force'          => \$force,      # force deletion
            'save-temps'     => \$save_temps, # Save temporary files?
            'dbname=s'       => \$dbname,     # Database name
@@ -104,8 +105,9 @@
 my $cam_path_base = $run->{cam_path_base};
 my $inverse = $run->{inverse};
+my $replace = $run->{re_place};
 
 
 &my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned";
-&my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw";
+&my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if ($stage eq "raw"); # XXX: add this once we implement and $replace;
 
 
@@ -126,5 +128,5 @@
             # we use the mask output from the camera stage for input and replace
             # the output of the chip stage with that mask as well.
-            my $cammask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
+            my $cammask   = $cam_path_base ? $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component) : undef;
 
             if ($backup_path_base) {
@@ -141,5 +143,5 @@
                 }
 
-                $bmask   = dirname($backup_path_base) . "/" . $prefix . basename($cammask);
+                $bmask   = dirname($backup_path_base) . "/" . $prefix . basename($cammask) if $cammask;
             }
             if ($recovery_path_base) {
@@ -148,5 +150,5 @@
                 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component);
                 # This is kludgey but correct
-                $rmask   = dirname($recovery_path_base) . "/" . basename($cammask);
+                $rmask   = dirname($recovery_path_base) . "/" . basename($cammask) if $cammask;;
             }
         } elsif ($stage eq "camera") {
@@ -226,6 +228,6 @@
                 if (!$no_update) {
                     print STDERR "deleting $file\n" if $verbose;
-                    $ipprc->file_delete($file, 1) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
-                    } else {
+                    $ipprc->file_delete($file, $force) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
+                } else {
                     print STDERR "skipping delete $file\n";
                 }
