Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Avoid possible issues when storing binary data #9

Merged
merged 1 commit into from

2 participants

@luislavena

This could be raised due encoding mismatch between the interpreter that stored the file and the interpreter that read the file.

@norman norman merged commit 2bccec3 into norman:master
@norman
Owner

Thanks!

@luislavena luislavena Avoid possible issues when storing binary data
This could be raised due encoding mismatch between the interpreter that stored the file and the interpreter that read the file.
810fecc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2011
  1. @luislavena

    Avoid possible issues when storing binary data

    luislavena authored
    This could be raised due encoding mismatch between the interpreter that stored the file and the interpreter that read the file.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/ambry/adapters/file.rb
View
5 lib/ambry/adapters/file.rb
@@ -25,12 +25,13 @@ def export_data
end
def import_data
- Marshal.load(::File.read(file_path))
+ data = ::File.open(file_path, "rb") { |f| f.read }
+ Marshal.load(data)
end
def save_database
@lock.synchronize do
- ::File.open(file_path, "w") {|f| f.write(export_data)}
+ ::File.open(file_path, "wb") {|f| f.write(export_data)}
end
end
end
Something went wrong with that request. Please try again.