Skip to content

Commit

Permalink
Fix File#write_buffer to always return the given io
Browse files Browse the repository at this point in the history
Ref: ef89a62

This fixes a regression in 2.4.rc1.

Cherry-picked into 3.0 for consistency.
  • Loading branch information
byroot authored and hainesr committed Apr 9, 2024
1 parent 0c0003c commit 5c6a7c9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/zip/file.rb
Expand Up @@ -301,7 +301,7 @@ def commit

# Write buffer write changes to buffer and return
def write_buffer(io = ::StringIO.new)
return unless commit_required?
return io unless commit_required?

::Zip::OutputStream.write_buffer(io) do |zos|
@cdir.each { |e| e.write_to_zip_output_stream(zos) }
Expand Down
2 changes: 1 addition & 1 deletion test/file_test.rb
Expand Up @@ -233,7 +233,7 @@ def test_open_buffer_without_block_write_buffer_does_nothing
assert zf.entries.map(&:name).include?('zippedruby1.rb')

# Ensure the buffer isn't changed.
zf.write_buffer(string_io)
assert_same(string_io, zf.write_buffer(string_io))
assert_equal(data, string_io.string)
end

Expand Down

0 comments on commit 5c6a7c9

Please sign in to comment.