diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pstore.rb | 11 | ||||
| -rw-r--r-- | lib/yaml/store.rb | 16 |
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb index 54d4e7c3a..a1ad768fb 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -413,8 +413,8 @@ class PStore if data.empty? # This seems to be a newly-created file. table = {} - checksum = EMPTY_MARSHAL_CHECKSUM - size = EMPTY_MARSHAL_DATA.size + checksum = empty_marshal_checksum + size = empty_marshal_data.size else table = load(data) checksum = Digest::MD5.digest(data) @@ -511,6 +511,13 @@ class PStore def load(content) # :nodoc: Marshal::load(content) end + + def empty_marshal_data + EMPTY_MARSHAL_DATA + end + def empty_marshal_checksum + EMPTY_MARSHAL_CHECKSUM + end end # :enddoc: diff --git a/lib/yaml/store.rb b/lib/yaml/store.rb index 4f0384cc5..e3a8e9fcd 100644 --- a/lib/yaml/store.rb +++ b/lib/yaml/store.rb @@ -20,10 +20,24 @@ class YAML::Store < PStore end def load(content) - YAML::load(content) + table = YAML::load(content) + if table == false + {} + else + table + end end def marshal_dump_supports_canonical_option? false end + + EMPTY_MARSHAL_DATA = {}.to_yaml + EMPTY_MARSHAL_CHECKSUM = Digest::MD5.digest(EMPTY_MARSHAL_DATA) + def empty_marshal_data + EMPTY_MARSHAL_DATA + end + def empty_marshal_checksum + EMPTY_MARSHAL_CHECKSUM + end end |
