Index: trunk/ippScripts/scripts/chip_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/chip_imfile.pl	(revision 35811)
+++ trunk/ippScripts/scripts/chip_imfile.pl	(revision 35894)
@@ -348,4 +348,18 @@
             }
         }
+        # resolve uri
+        my $uriReal = $ipprc->file_resolve( $uri );
+        # If instance is not found or if it doesn't exist try running neb-repair on it 
+        # Note: file_exists returns false if the file exists but has zero size
+        if (!$uriReal or !$ipprc->file_exists($uriReal)) {
+            my $repair_cmd = "$nebrepair $uri";
+            my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
+            unless ($repair_success) {
+                &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
+            }
+            $uriReal = $ipprc->file_resolve( $uri );
+        }
+            
+        &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
 
         # if recipe option PPIMAGE:APPLY.BURNTOOL is set and the burntool information is stored in
@@ -378,18 +392,4 @@
             my ($tempFile, $tempName) = tempfile( "/tmp/chip.$exp_id.$class_id.deburned.XXXX",
                                               UNLINK => !$save_temps, SUFFIX => '.fits' );
-
-            # get the UNIX version of the (possible) neb: or path: filename
-            my $uriReal = $ipprc->file_resolve( $uri );
-                # Catch errors here
-            if (!$uriReal) {
-                my $repair_cmd = "$nebrepair $uri";
-                my ($repair_success, $repair_error_code, $repair_full_buf, $repair_stdout_buf, $repair_stderr_buf ) = run(command => $repair_cmd, verbose => $verbose);
-                unless ($repair_success) {
-                    &my_die("Unable to attempt repair: $uri $repair_error_code", $exp_id,$chip_id, $class_id, $PS_EXIT_SYS_ERROR);
-                }
-                $uriReal = $ipprc->file_resolve( $uri );
-            }
-                
-            &my_die("Unable to resolve $uri on $host", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR) if !$uriReal;
 
             # funpack into the temp file.
