Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,18 @@ def open_buffer(io, options = {})
if io.is_a?(::String)
require 'stringio'
io = ::StringIO.new(io)
elsif io.is_a?(IO)
# https://github.com/rubyzip/rubyzip/issues/119
io.binmode
end
zf = ::Zip::File.new(io, true, true, options)
zf.read_from_stream(io)
yield zf
zf.write_buffer(io)
begin
zf.write_buffer(io)
rescue IOError => e
raise unless e.message == "not opened for writing"
end
end

# Iterates over the contents of the ZipFile. This is more efficient
Expand Down
2 changes: 1 addition & 1 deletion lib/zip/output_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(file_name, stream=false)
@file_name = file_name
@output_stream = if stream
iostream = @file_name.dup
iostream.reopen
iostream.reopen(@file_name)
iostream.rewind
iostream
else
Expand Down