Make sure to delete the output file in case of an exception.
[redact.git] / lib / redact / app.rb
index dc9ef9b52b4d52bb8fb8697e0a0cd1f26c452eeb..2cc9dd7cf74b7022948a0d207380bb08127c32ab 100644 (file)
@@ -1,5 +1,5 @@
 #--
-# $Id: app.rb 39 2005-04-28 21:08:11Z tilman $
+# $Id: app.rb 40 2005-05-25 20:19:45Z tilman $
 #
 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
 #
@@ -66,15 +66,20 @@ module Redact
 
                        amx = compile_embryo
 
-                       Eet::File.open(@options.output, "w") do |ef|
-                               dump_amx(amx, ef)
-
-                               dump_header(ef)
-                               dump_collections(ef)
-                               dump_fonts(ef)
-                               dump_images(ef)
-                               dump_source(ef)
-                               dump_fontmap(ef)
+                       begin
+                               Eet::File.open(@options.output, "w") do |ef|
+                                       dump_amx(amx, ef)
+
+                                       dump_header(ef)
+                                       dump_collections(ef)
+                                       dump_fonts(ef)
+                                       dump_images(ef)
+                                       dump_source(ef)
+                                       dump_fontmap(ef)
+                               end
+                       rescue Exception
+                               File.rm_f(@options.output)
+                               raise
                        end
                end