Index: trunk/ippScripts/scripts/magic_destreak_revert.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 30260)
+++ trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 30670)
@@ -191,5 +191,5 @@
     # Note that when destreaking as part of an update $magicked is non-zero.
     # In this case we do not touch the camera stage mask so there is no need to revert it
-    if (!$magicked and $dynamicMasks) {
+    if ($dynamicMasks and (!$magicked or ($run_state eq 'goto_restored'))) {
         $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
         $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
@@ -210,9 +210,11 @@
     $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id);
 
-    $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $class_id);
-    # This is somewhat kludgey but it works whether the mask is camera mask or chip mask
-    $rmask   = dirname($recovery_path_base) . "/REC_" . basename($mask);
-    $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $class_id);
-    $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $class_id);
+    if ($recovery_path_base) {
+        $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $class_id);
+        # This is somewhat kludgey but it works whether the mask is camera mask or chip mask
+        $rmask   = dirname($recovery_path_base) . "/REC_" . basename($mask);
+        $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $class_id);
+        $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $class_id);
+    }
 } elsif ($stage eq "camera") {
     $astrom =  $ipprc->filename("PSASTRO.OUTPUT", $path_base);
@@ -227,7 +229,9 @@
     $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base);
     $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base);
-    $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
-    $rmask   = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base);
-    $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
+    if ($recovery_path_base) {
+        $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
+        $rmask   = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base);
+        $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
+    }
 } elsif ($stage eq "diff") {
     my $name = "PPSUB.OUTPUT";
