Skip to content

Commit

Permalink
Remove Entry#dirty= as 'dirtyness' is now monitored internally.
Browse files Browse the repository at this point in the history
Had to round out some of the accessors that mark an `Entry` as dirty.
  • Loading branch information
hainesr committed Feb 7, 2022
1 parent bfd528d commit 3c2abb5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class Entry
:restore_ownership, :restore_permissions, :restore_times,
:size, :unix_gid, :unix_perms, :unix_uid

attr_accessor :crc, :dirty, :external_file_attributes, :fstype, :gp_flags,
attr_accessor :crc, :external_file_attributes, :fstype, :gp_flags,
:internal_file_attributes, :local_header_offset # :nodoc:

attr_reader :extra, :compression_level, :ftype, :filepath # :nodoc:

mark_dirty :comment=, :compressed_size=, :name=, :size=,
mark_dirty :comment=, :compressed_size=, :external_file_attributes=,
:fstype=, :gp_flags=, :name=, :size=,
:unix_gid=, :unix_perms=, :unix_uid=

def set_default_vars_values
Expand Down
1 change: 0 additions & 1 deletion lib/zip/filesystem/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def chmod(mode, *filenames)
e.fstype = FSTYPE_UNIX # Force conversion filesystem type to unix.
e.unix_perms = mode
e.external_file_attributes = mode << 16
e.dirty = true
end
filenames.size
end
Expand Down
8 changes: 5 additions & 3 deletions test/entry_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,18 @@ def test_delete
def test_each
# Used each instead each_with_index due the bug in jRuby
count = 0
new_size = 200
@zip_entry_set.each do |entry|
assert(ZIP_ENTRIES.include?(entry))
assert(entry.dirty)
entry.dirty = false # Check that entries can be changed in this block.
entry.clean_up # Start from a "saved" state.
entry.size = new_size # Check that entries can be changed in this block.
count += 1
end

assert_equal(ZIP_ENTRIES.size, count)
@zip_entry_set.each do |entry|
refute(entry.dirty)
assert_equal(new_size, entry.size)
assert(entry.dirty?) # Size was changed.
end
end

Expand Down

0 comments on commit 3c2abb5

Please sign in to comment.