8000 Sync options and fix inconsistent behaviour of `Zip::File#get_entry` and `Zip::File#find_entry`. by hainesr · Pull Request #423 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Sync options and fix inconsistent behaviour of Zip::File#get_entry and Zip::File#find_entry. #423

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 4 commits into from
Dec 15, 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
Prev Previous commit
Next Next commit
Ensure File#get/find_entry work consistently.
I have switched around the logic somewhat so that `get_entry` calls
`find_entry` and raises an exception if it gets `nil` back.
  • Loading branch information
hainesr committed Oct 31, 2019
commit 2d6b6e024b1093f19b7ea9da2b5f33eb2d32df9e
14 changes: 9 additions & 5 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,13 @@ def commit_required?
# Searches for entry with the specified name. Returns nil if
# no entry is found. See also get_entry
def find_entry(entry_name)
@entry_set.find_entry(entry_name)
selected_entry = @entry_set.find_entry(entry_name)
return if selected_entry.nil?

selected_entry.restore_ownership = @restore_ownership
selected_entry.restore_permissions = @restore_permissions
selected_entry.restore_times = @restore_times
selected_entry
end

# Searches for entries given a glob
Expand All @@ -388,10 +394,8 @@ def glob(*args, &block)
# if no entry is found.
def get_entry(entry)
selected_entry = find_entry(entry)
raise Errno::ENOENT, entry unless selected_entry
selected_entry.restore_ownership = @restore_ownership
selected_entry.restore_permissions = @restore_permissions
selected_entry.restore_times = @restore_times
raise Errno::ENOENT, entry if selected_entry.nil?

selected_entry
end

Expand Down
0