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

Be smarter about handling buffer file modes #201

Merged
merged 1 commit into from Jan 17, 2015
Merged

Be smarter about handling buffer file modes #201

merged 1 commit into from Jan 17, 2015

Conversation

changemewtf
Copy link
Contributor

This is a fix for #119.

The test suite still runs, but I have not added a test for this fix because I'm not sure if the behavior I defined is correct.

  1. Force binary mode (file.rb): I noticed that the errors went away when I opened files in binary mode, like rubyzip itself does when you pass a filename to Zip::File.open, so now it forces binary mode when you pass an IO object.
  2. Abort unnecessary writes (output_stream.rb): If you don't pass a stream which was opened for writing, then this results in a "not opened for writing" error, even if you didn't actually try to write anything.

The second part is probably not correct; I imagine the best fix would be one that only bothers doing zf.write_buffer(io) if changes were actually made to the in-memory archive.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.13%) when pulling 7c7d786 on mcantor:master into e938438 on rubyzip:master.

simonoff added a commit that referenced this pull request Jan 17, 2015
Be smarter about handling buffer file modes
@simonoff simonoff merged commit 721c1f0 into rubyzip:master Jan 17, 2015
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 this pull request may close these issues.

None yet

3 participants