8000 Fix restore options consistency. by hainesr · Pull Request #486 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Fix restore options consistency. #486

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 7 commits into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
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
Move the restore options to the top level.
This will ensure consistency between `File` and `Entry`.
  • Loading branch information
hainesr committed Jun 6, 2021
commit 78b9c21a9953257a35f7cd9f98b59d26f239d92d
6 changes: 6 additions & 0 deletions lib/zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ module Zip
:force_entry_names_encoding,
:validate_entry_sizes

DEFAULT_RESTORE_OPTIONS = {
restore_ownership: false,
restore_permissions: false,
restore_times: false
}.freeze

def reset!
@_ran_once = false
@unicode_names = false
Expand Down
6 changes: 3 additions & 3 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def set_default_vars_values
end
@follow_symlinks = false

@restore_times = false
@restore_permissions = false
@restore_ownership = false
@restore_times = DEFAULT_RESTORE_OPTIONS[:restore_times]
@restore_permissions = DEFAULT_RESTORE_OPTIONS[:restore_permissions]
@restore_ownership = DEFAULT_RESTORE_OPTIONS[:restore_ownership]
# BUG: need an extra field to support uid/gid's
@unix_uid = nil
@unix_gid = nil
Expand Down
8 changes: 1 addition & 7 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ class File < CentralDirectory
DATA_BUFFER_SIZE = 8192
IO_METHODS = [:tell, :seek, :read, :eof, :close].freeze

DEFAULT_OPTIONS = {
restore_ownership: false,
restore_permissions: false,
restore_times: false
}.freeze

attr_reader :name

# default -> false.
Expand All @@ -77,7 +71,7 @@ class File < CentralDirectory
# a new archive if it doesn't exist already.
def initialize(path_or_io, create = false, buffer = false, options = {})
super()
options = DEFAULT_OPTIONS
options = DEFAULT_RESTORE_OPTIONS
.merge(compression_level: ::Zip.default_compression)
.merge(options)
@name = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io
Expand Down
0