Index: trunk/ippScripts/scripts/magic_destreak_revert.pl
===================================================================
--- trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 24894)
+++ trunk/ippScripts/scripts/magic_destreak_revert.pl	(revision 24936)
@@ -95,5 +95,5 @@
 } elsif ($stage eq "diff") {
     $skycell_id = $component;
-} else {
+} elsif ($stage ne "camera") {
     &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
 }
@@ -142,6 +142,6 @@
 
 
-my ($image, $mask, $ch_mask, $weight, $sources);
-my ($bimage, $bmask, $bch_mask, $bweight, $bsources);
+my ($image, $mask, $ch_mask, $weight, $sources, $astrom);
+my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom);
 
 if ($stage eq "raw") {
@@ -167,4 +167,7 @@
     $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id);
     $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id);
+} elsif ($stage eq "camera") {
+    $astrom =  $ipprc->filename("PSASTRO.OUTPUT", $path_base);
+    $bastrom = $ipprc->filename("PSASTRO.OUTPUT", $backup_path_base);
 } elsif ($stage eq "warp") {
     $image  = $ipprc->filename("PSWARP.OUTPUT", $path_base);
@@ -188,14 +191,15 @@
 }
 
-revert_file($image, $bimage) or
+if ($image) {
+    revert_file($image, $bimage) or
         &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
-
-# don't commit next the next couple of lines and see xxx below
-# change to if 0 to revert chip runs without masks
+}
+
 if ($mask) {
     if (!revert_file($mask, $bmask)) {
         if ($stage eq 'chip') {
-            # XXX: don't fail if the mask file fails to revert. It probably doesn't exist
-            # Handle this properly
+            # don't fail if the mask file (from the camera stage) fails to revert.
+            # It probably doesn't exist
+            # XXX: Handle this properly
             print STDERR "failure to revert mask file, ignored\n";
         } else {
@@ -206,7 +210,5 @@
 
 if ($ch_mask) {
-    # Handle this properly
     if (!revert_file($ch_mask, $bch_mask)) {
-        # print STDERR "failure to revert chip mask file, ignored\n";
         &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
     }
@@ -222,4 +224,9 @@
     revert_file($sources, $bsources) or
         &my_die("failed to restore sources file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
+}
+
+if ($astrom) {
+    revert_file($astrom, $bastrom) or
+        &my_die("failed to restore astrometry file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
 }
 
