summaryrefslogtreecommitdiff
path: root/lib/pstore.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pstore.rb')
-rw-r--r--lib/pstore.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb
index dfec76e..dd74f4f 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -102,7 +102,7 @@ class PStore
file.flock(read_only ? File::LOCK_SH : File::LOCK_EX)
if read_only
@table = Marshal::load(file)
- elsif orig and (content = file.read) != nil
+ elsif orig and (content = file.read) != ""
@table = Marshal::load(content)
size = content.size
md5 = Digest::MD5.digest(content)
@@ -118,7 +118,7 @@ class PStore
@abort = true
raise
ensure
- if !read_only && !@abort
+ if !read_only and !@abort
file.rewind
content = Marshal::dump(@table)
if !md5 || size != content.size || md5 != Digest::MD5.digest(content)
@@ -133,6 +133,9 @@ class PStore
end
end
end
+ if @abort and !orig
+ File.unlink(@filename)
+ end
@abort = false
end
ensure