Backport #5311 ยป pstore_ensure_binary.patch
lib/pstore.rb (working copy) | ||
---|---|---|
def open_and_lock_file(filename, read_only)
|
||
if read_only
|
||
begin
|
||
file = File.new(filename, RD_ACCESS)
|
||
file = File.new(filename, RD_ACCESS, external_encoding: Encoding::BINARY)
|
||
begin
|
||
file.flock(File::LOCK_SH)
|
||
return file
|
||
... | ... | |
return nil
|
||
end
|
||
else
|
||
file = File.new(filename, RDWR_ACCESS)
|
||
file = File.new(filename, RDWR_ACCESS, external_encoding: Encoding::BINARY)
|
||
file.flock(File::LOCK_EX)
|
||
return file
|
||
end
|
test/test_pstore.rb (working copy) | ||
---|---|---|
pstore.transaction { pstore.transaction { } }
|
||
end
|
||
end
|
||
# Test that PStore's file operations do not blow up when default encodings are set
|
||
def test_pstore_files_are_accessed_as_binary_files
|
||
Encoding.default_internal = 'utf-8'
|
||
Encoding.default_external = 'utf-8'
|
||
(1..1000).each do |i|
|
||
@pstore.transaction { @pstore["Key#{i}"] = "value #{i}" }
|
||
end
|
||
end
|
||
end
|