8000 Fix #280 - `open_buffer` mangles the content of the buffer it is given. by hainesr · Pull Request #360 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Fix #280 - open_buffer mangles the content of the buffer it is given. #360

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

Merged
merged 5 commits into from
Sep 5, 2019
Merged
Changes from 1 commit
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
Next Next commit
Clean up use of file_name in Zip::File::initialize.
  • Loading branch information
hainesr committed Apr 3, 2018
commit 7cd263e6a0d53f793ba41b249f4a78f84c4dc016
12 changes: 6 additions & 6 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ def initialize(file_name, create = false, buffer = false, options = {})
@name = file_name
@comment = ''
@create = create ? true : false # allow any truthy value to mean true
if !buffer && ::File.size?(file_name)
if !buffer && ::File.size?(@name)
@create = false
@file_permissions = ::File.stat(file_name).mode
::File.open(name, 'rb') do |f|
@file_permissions = ::File.stat(@name).mode
::File.open(@name, 'rb') do |f|
read_from_stream(f)
end
elsif @create
@entry_set = EntrySet.new
elsif ::File.zero?(file_name)
raise Error, "File #{file_name} has zero size. Did you mean to pass the create flag?"
elsif ::File.zero?(@name)
raise Error, "File #{@name} has zero size. Did you mean to pass the create flag?"
else
raise Error, "File #{file_name} not found"
raise Error, "File #{@name} not found"
end
@stored_entries = @entry_set.dup
@stored_comment = @comment
Expand Down
0