From c54cd09e4e3ed7e04e6e2e144b86070851baac43 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Tue, 6 Aug 2002 23:07:25 +0000 Subject: [PATCH] better file renaming (don't lose that file) --- trunk/ripnews/ripnews.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/trunk/ripnews/ripnews.rb b/trunk/ripnews/ripnews.rb index a2c5691..141bb08 100755 --- a/trunk/ripnews/ripnews.rb +++ b/trunk/ripnews/ripnews.rb @@ -53,6 +53,20 @@ def save_file(dir, name, data) print "couldn't open file for writeing\n" return false end + when "Tempfile" + begin + if File.rename(data.path, "#{dir}/#{newname}") + print " Saving as: '#{newname}'\n" + else + print "couldn't rename tempfile\n" + return false + end + rescue Errno::ENOENT + print "Caught Errno::ENOENT (save_file)\n" + print "Error: #{$!}\n" + print "What the #@$$ happended?\n" + return false + end else print "EEEEPS Can't save data of type: #{data.type.to_s}\n" return false @@ -252,6 +266,9 @@ def get_multi(subj, group) end return false unless check_ext(filename, "m") body = fileout.path + bodybase = body.sub(/\/[^\/]*$/, "") + File.rename(body, "#{bodybase}/ripnewsdecode") + body = "#{bodybase}/ripnewsdecode" file.close fileout.close(false) return mode, filename, body