Index: trunk/ippScripts/scripts/magic_process.pl
===================================================================
--- trunk/ippScripts/scripts/magic_process.pl	(revision 27596)
+++ trunk/ippScripts/scripts/magic_process.pl	(revision 27634)
@@ -142,12 +142,10 @@
         my $tempName = $innode->{inverse} ? "PPSUB.INPUT.CONV" : "PPSUB.REF.CONV"; # File rule of interest
         my $template = $ipprc->file_resolve($ipprc->filename($tempName, $diff_base));
-        &my_die("failed to resolve template", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless defined $template;
 
         # Delete the convolved products when done (we can recreate them as we need)
-        push @deletions, $template;
         push @deletions, $ipprc->filename($tempName . ".MASK", $diff_base);
         push @deletions, $ipprc->filename($tempName . ".VARIANCE", $diff_base);
 
-        unless ($ipprc->file_exists($template)) {
+        unless (defined $template and $ipprc->file_exists($template)) {
             # Template doesn't exist (or can't be found); try to recreate it
             my $tempPath = "/tmp/magic.$magic_id.$node.template";
@@ -208,7 +206,9 @@
                 $template = $ipprc->file_resolve($template) or &my_die("Unable to resolve filename for created template", $magic_id, $node, $PS_EXIT_PROG_ERROR);
                 &my_die("Unable to find created template", $magic_id, $node, $PS_EXIT_PROG_ERROR) unless $ipprc->file_exists($template);
-                push @deletions, $template;
             }
         }
+
+        &my_die("Cannot find template", $magic_id, $node, $PS_EXIT_DATA_ERROR) unless defined $template and $ipprc->file_exists($template);
+        push @deletions, $template;
 
         $command .= " --detect --image $image --mask $mask --weight $weight -k $template";
