Index: trunk/ippScripts/scripts/stack_skycell.pl
===================================================================
--- trunk/ippScripts/scripts/stack_skycell.pl	(revision 21309)
+++ trunk/ippScripts/scripts/stack_skycell.pl	(revision 21330)
@@ -66,6 +66,8 @@
     $logDest .= ".update";
 }
+
 $ipprc->redirect_output($logDest) if $redirect;
 
+my $temp_images_exist = 0;
 my $image_id = $stack_id;
 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_STACK);
@@ -192,4 +194,5 @@
 $traceDest .= ".update" if $run_state eq 'update';
 my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot);
+$temp_images_exist = 1;  # failures after this point should attempt to delete the temp images
 
 # for update we need to resolve the config filename here because the code that reads it
@@ -287,5 +290,5 @@
 
 
-
+my $my_die_called = 0;
 sub my_die
 {
@@ -296,5 +299,8 @@
     carp($msg);
 
-    delete_temps() unless ($save_temps);
+    unless ($my_die_called) {
+	$my_die_called = 1;
+	delete_temps() unless ($save_temps);
+    }
 
     if (defined $stack_id and not $no_update) {
@@ -317,4 +323,9 @@
 sub delete_temps
 {
+    unless ($temp_images_exist) {
+	print "No temporary images yet generated\n";
+	return 1;
+    }
+
     print "Ensuring temporary images are deleted.\n";
     my $command = "$ppConfigDump -camera $camera -recipe PPSTACK $recipe_ppStack -dump-recipe PPSTACK -";
@@ -323,8 +334,8 @@
     unless ($success) {
         $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
-        &my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
+	&my_die("Unable to perform ppConfigDump: $error_code", $stack_id, $error_code);
     }
     my $md = $mdcParser->parse(join "", @$stdout_buf) or
-        &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
+	&my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
 
     my $temp_delete = metadataLookupBool($md, 'TEMP.DELETE'); # Delete temporary files?
