Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling Zip::File.open_buffer(io) #146

Closed
davidblondeau opened this issue Mar 21, 2014 · 2 comments
Closed

Error when calling Zip::File.open_buffer(io) #146

davidblondeau opened this issue Mar 21, 2014 · 2 comments

Comments

@davidblondeau
Copy link

Just updated from 1.1.0 to 1.1.2 and it seems like the call to reopen in OutputStream is causing an issue.

If you run the following code after replacing "something.zip" with the path to an actual file, you get the error that follows.

File.open("something.zip") do |io|
  io.set_encoding(Encoding::BINARY)
  Zip::File.open_buffer(io) do |zip_io|
    // left empty on purpose
  end
end
ArgumentError: wrong number of arguments (0 for 1..2)
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/output_stream.rb:32:in `reopen'
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/output_stream.rb:32:in `initialize'
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/output_stream.rb:59:in `new'
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/output_stream.rb:59:in `write_buffer'
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/file.rb:316:in `write_buffer'
    from vendor/ruby/1.9.1/gems/rubyzip-1.1.2/lib/zip/file.rb:128:in `open_buffer'
    from (irb):21:in `block in irb_binding'
    from (irb):19:in `open'
    from (irb):19
    from /Users/work/.rvm/rubies/ruby-1.9.3-p484/bin/irb:12:in `<main>'
@cpence
Copy link

cpence commented Mar 25, 2014

This is the same bug as #143, which was fixed in 1.1.2, but the fix didn't catch OutputStream.

@jdleesmiller
Copy link
Member

I think this was fixed some time ago, but to be safe I have added a test case, which presently passes:

rubyzip/test/file_test.rb

Lines 134 to 141 in eeef507

def test_open_buffer_with_io_and_block
File.open('test/data/rubycode.zip') do |io|
io.set_encoding(Encoding::BINARY) # not strictly required but can be set
Zip::File.open_buffer(io) do |zip_io|
# left empty on purpose
end
end
end

So, I'll close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants