summaryrefslogtreecommitdiff
path: root/lib/pstore.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pstore.rb')
-rw-r--r--lib/pstore.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb
index b93420d649..3f95e8c059 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -15,7 +15,8 @@
require "marshal"
class PStore
- Exception(:Error)
+ class Error < StandardError
+ end
def initialize(file)
dir = File::dirname(file)
@@ -90,13 +91,17 @@ class PStore
end
ensure
unless @abort
- File::rename @filename, @filename+"~"
+ begin
+ File::rename @filename, @filename+"~"
+ rescue Errno::ENOENT
+ no_orig = true
+ end
begin
File::open(@filename, "w") do |file|
Marshal::dump(@table, file)
end
rescue
- File::rename @filename+"~", @filename
+ File::rename @filename+"~", @filename unless no_orig
end
end
@abort = false