Re-initialize CDir after a `commit`.
Using the factored-out code preserves options set in `File`. Fixes #529.
This commit is contained in:
parent
c243b4429a
commit
14ff11ba05
|
@ -267,7 +267,7 @@ module Zip
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
initialize(name)
|
initialize_cdir(@name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Write buffer write changes to buffer and return
|
# Write buffer write changes to buffer and return
|
||||||
|
|
|
@ -640,6 +640,16 @@ class ZipFileTest < MiniTest::Test
|
||||||
assert_equal(res, true)
|
assert_equal(res, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_commit_preserves_options
|
||||||
|
zip_file = 'test/data/generated/preserve_options.zip'
|
||||||
|
::Zip::File.open(zip_file, create: true, compression_level: 8) do |zf|
|
||||||
|
assert(zf.commit_required?)
|
||||||
|
zf.commit
|
||||||
|
assert_equal(8, zf.instance_variable_get(:@compression_level))
|
||||||
|
refute(zf.commit_required?)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_double_commit(filename = 'test/data/generated/double_commit_test.zip')
|
def test_double_commit(filename = 'test/data/generated/double_commit_test.zip')
|
||||||
::FileUtils.touch('test/data/generated/test_double_commit1.txt')
|
::FileUtils.touch('test/data/generated/test_double_commit1.txt')
|
||||||
::FileUtils.touch('test/data/generated/test_double_commit2.txt')
|
::FileUtils.touch('test/data/generated/test_double_commit2.txt')
|
||||||
|
|
Loading…
Reference in New Issue