summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 21:09:43 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 21:09:43 +0000
commit6c0ef220d25d7a569c38e53730377a2ff8eb92b7 (patch)
tree69c4486ec7dcb8971745fbc64b36f0d707fcc96e /lib
parentfa5cda0fe01afd7e06560ab28a3d125e81d14ec9 (diff)
Safe-save tempfiles are now created in a botclass-local directory, because atomic renaming only works within a filesystem
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/ircbot.rb2
-rw-r--r--lib/rbot/utils.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index ac7aa829..8249895b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -266,6 +266,8 @@ class IrcBot
Dir.mkdir("#{botclass}/logs") unless File.exist?("#{botclass}/logs")
Dir.mkdir("#{botclass}/registry") unless File.exist?("#{botclass}/registry")
+ Dir.mkdir("#{botclass}/safe_save") unless File.exist?("#{botclass}/safe_save")
+ Utils.set_safe_save_dir("#{botclass}/safe_save")
@ping_timer = nil
@pong_timer = nil
diff --git a/lib/rbot/utils.rb b/lib/rbot/utils.rb
index ae45e5d5..d1052390 100644
--- a/lib/rbot/utils.rb
+++ b/lib/rbot/utils.rb
@@ -320,9 +320,15 @@ module Irc
end
+ @@safe_save_dir = nil
+ def Utils.set_safe_save_dir(str)
+ @@safe_save_dir = str.dup
+ end
+
def Utils.safe_save(file)
+ raise 'No safe save directory defined!' if @@safe_save_dir.nil?
basename = File.basename(file)
- temp = Tempfile.new(basename)
+ temp = Tempfile.new(basename,@@safe_save_dir)
temp.binmode
yield temp if block_given?
temp.close