Skip to content

Commit

Permalink
Mark other mutating methods in Entry as dirty.
Browse files Browse the repository at this point in the history
Also, remove `Entry#extra=` as it makes no sense (and wasn't even being
tested).

And remove slightly odd test that was assuming an archive would not be
changed if its utime was changed - even if it was being changed back
immediately. This test was merely confirming that we weren't catching
timestamp changes correctly.
  • Loading branch information
hainesr committed Feb 21, 2022
1 parent 3c2abb5 commit 7230a50
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Lint/MissingSuper:
# Offense count: 5
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 620
Max: 630

# Offense count: 21
# Configuration parameters: IgnoredMethods.
Expand Down
10 changes: 2 additions & 8 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ def incomplete?
gp_flags & 8 == 8
end

def extra=(field)
@extra = if field.nil?
ExtraField.new
else
field.kind_of?(ExtraField) ? field : ExtraField.new(field.to_s)
end
end

def time
if @extra['UniversalTime'] && !@extra['UniversalTime'].mtime.nil?
@extra['UniversalTime'].mtime
Expand All @@ -141,6 +133,7 @@ def time
alias mtime time

def time=(value)
@dirty = true
unless @extra.member?('UniversalTime') || @extra.member?('NTFS')
@extra.create('UniversalTime')
end
Expand All @@ -157,6 +150,7 @@ def compression_method
end

def compression_method=(method)
@dirty = true
@compression_method = (@ftype == :directory ? STORED : method)
end

Expand Down
9 changes: 0 additions & 9 deletions test/filesystem/file_nonmutating_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,6 @@ def test_join
assert_equal('a/b/c/d', @zip_file.file.join('a', 'b', 'c', 'd'))
end

def test_utime
t_now = ::Zip::DOSTime.now
t_bak = @zip_file.file.mtime('file1')
@zip_file.file.utime(t_now, 'file1')
assert_equal(t_now, @zip_file.file.mtime('file1'))
@zip_file.file.utime(t_bak, 'file1')
assert_equal(t_bak, @zip_file.file.mtime('file1'))
end

def assert_always_false(operation)
assert(!@zip_file.file.send(operation, 'noSuchFile'))
assert(!@zip_file.file.send(operation, 'file1'))
Expand Down

0 comments on commit 7230a50

Please sign in to comment.