From 7f93c3f711785cc1215d17a9ab412998260745f0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 17 Sep 2008 16:48:16 -0700 Subject: [PATCH] mog: ensure the tempfile is killed at death --- bin/mog | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/mog b/bin/mog index 06bd481..f17427c 100755 --- a/bin/mog +++ b/bin/mog @@ -155,9 +155,13 @@ begin cfg[:class] or raise ArgumentError, 'E: --class must be specified' buf = '' tmp = Tempfile.new('mog-tee') # TODO: explore Transfer-Encoding:chunked :) - sysrwloop(STDIN, tmp) - mg.store_file(key, cfg[:class], tmp.path) - tmp.close + at_exit { tmp.unlink } + begin + sysrwloop(STDIN, tmp) + mg.store_file(key, cfg[:class], tmp.path) + ensure + tmp.close + end else raise ArgumentError, "Unknown command: #{cmd}" end -- 2.11.4.GIT