8000 Correctly set/default options in the File class. · rubyzip/rubyzip@2534575 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2534575

Browse files
committed
Correctly set/default options in the File class.
Fixes #395. Set the options to false for now for consistency.
1 parent e43e360 commit 2534575

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/zip/file.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class File < CentralDirectory
5151
DATA_BUFFER_SIZE = 8192
5252
IO_METHODS = [:tell, :seek, :read, :close]
5353

54+
DEFAULT_OPTIONS = {
55+
restore_ownership: false,
56+
restore_permissions: false,
57+
restore_times: false
58+
}.freeze
59+
5460
attr_reader :name
5561

5662
# default -> false
@@ -66,6 +72,7 @@ class File < CentralDirectory
6672
# a new archive if it doesn't exist already.
6773
def initialize(path_or_io, create = false, buffer = false, options = {})
6874
super()
75+
options = DEFAULT_OPTIONS.merge(options)
6976
@name = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io
7077
@comment = ''
7178
@create = create ? true : false # allow any truthy value to mean true
@@ -98,9 +105,9 @@ def initialize(path_or_io, create = false, buffer = false, options = {})
98105

99106
@stored_entries = @entry_set.dup
100107
@stored_comment = @comment
101-
@restore_ownership = options[:restore_ownership] || false
102-
@restore_permissions = options[:restore_permissions] || true
103-
@restore_times = options[:restore_times] || true
108+
@restore_ownership = options[:restore_ownership]
109+
@restore_permissions = options[:restore_permissions]
110+
@restore_times = options[:restore_times]
104111
end
105112

106113
class << self

0 commit comments

Comments
 (0)
0