Skip to content

Commit

Permalink
Move the restore options to the top level.
Browse files Browse the repository at this point in the history
This will ensure consistency between `File` and `Entry`.
  • Loading branch information
hainesr committed May 31, 2021
1 parent ca51c7c commit 83df65c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
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 comments on commit 83df65c

Please sign in to comment.