zip_tricks 4.8.0 → 4.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5c7e14be1038151588e016705af5249cacbfea8a
4
- data.tar.gz: fc4e68ce38ea2091f7a718a8dcfff09d3e40fbb6
2
+ SHA256:
3
+ metadata.gz: abccaae29c08d47d71a7c6709fbba2ccffce423798dbb159bbfdc9f832eafc93
4
+ data.tar.gz: ba5375f2fbd1617ffdf6c42ddd690f211e771c6eb4cb84c8a2e9323784acfd7c
5
5
  SHA512:
6
- metadata.gz: 05d776ff8a5c0cea81f66aba9ac37ad2400c0abea38660ca94365f15649c5d9cc8c06f6d768d2f657b70fae823fe6704bcd335611ff9693e9550246cc04ba7e6
7
- data.tar.gz: de2264703c398fba2d9a0c44b485206f2acdfb119c9aff76ab8855e2d84cdc2be4da6802af7fbe967f780229d8582d256439ee923c59aa0782d4b1d07b9104f0
6
+ metadata.gz: dbd7498e71a1dbb967374a2360e2216ab33924ba263600f795e11787b759aa08c5b2ba3b5085bc4a8362026e87098f18552d0409e23ab03375cf0d89e8bd20d8
7
+ data.tar.gz: f337fba0f07875b449ba3b5f5a593b30b2b810ca2aa79b473942a751a47d1db4c0ebbbe099faa474fe4c7a952b1ee030f6f94ed319835a3ba73c1e7cf65648e5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.8.1
2
+
3
+ * Fix extended timestamp extra field output. The first bit of the flag would be set instead of the last bit of
4
+ the flag, which made it impossible for Rubyzip to read the timestamp of the entry - and it would also make
5
+ the extra field useless for most reading applications.
6
+
1
7
  ## 4.8.0
2
8
 
3
9
  * Make sure that when directories clobber files and vice versa we raise a clear error. Add `PathSet` which keeps track of entries
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZipTricks
4
- VERSION = '4.8.0'
4
+ VERSION = '4.8.1'
5
5
  end
@@ -118,7 +118,7 @@ class ZipTricks::ZipWriter
118
118
  if requires_zip64
119
119
  extra_fields << zip_64_extra_for_local_file_header(compressed_size: compressed_size, uncompressed_size: uncompressed_size)
120
120
  end
121
- extra_fields << timestamp_extra(mtime)
121
+ extra_fields << timestamp_extra_for_local_file_header(mtime)
122
122
 
123
123
  io << [extra_fields.size].pack(C_UINT2) # extra field length 2 bytes
124
124
 
@@ -182,7 +182,7 @@ class ZipTricks::ZipWriter
182
182
  compressed_size: compressed_size,
183
183
  uncompressed_size: uncompressed_size)
184
184
  end
185
- extra_fields << timestamp_extra(mtime)
185
+ extra_fields << timestamp_extra_for_central_directory_entry(mtime)
186
186
 
187
187
  io << [extra_fields.size].pack(C_UINT2) # extra field length 2 bytes
188
188
 
@@ -345,12 +345,14 @@ class ZipTricks::ZipWriter
345
345
  pack_array(data_and_packspecs)
346
346
  end
347
347
 
348
- # Writes the extended timestamp information field. The spec defines 2
348
+ # Writes the extended timestamp information field for local headers.
349
+ #
350
+ # The spec defines 2
349
351
  # different formats - the one for the local file header can also accomodate the
350
352
  # atime and ctime, whereas the one for the central directory can only take
351
353
  # the mtime - and refers the reader to the local header extra to obtain the
352
354
  # remaining times
353
- def timestamp_extra(mtime)
355
+ def timestamp_extra_for_local_file_header(mtime)
354
356
  # Local-header version:
355
357
  #
356
358
  # Value Size Description
@@ -378,16 +380,21 @@ class ZipTricks::ZipWriter
378
380
  # bit 1 if set, access time is present
379
381
  # bit 2 if set, creation time is present
380
382
  # bits 3-7 reserved for additional timestamps; not set
381
- flags = 0b10000000 # Set bit 1 only to indicate only mtime is present
383
+ flags = 0b00000001 # Set the lowest bit only, to indicate that only mtime is present
382
384
  data_and_packspecs = [
383
385
  0x5455, C_UINT2, # tag for this extra block type ("UT")
384
- (1 + 4), C_UINT2, # the size of this block (1 byte used for the Flag + 1 long used for the timestamp)
386
+ (1 + 4), C_UINT2, # the size of this block (1 byte used for the Flag + 3 longs used for the timestamp)
385
387
  flags, C_CHAR, # encode a single byte
386
388
  mtime.utc.to_i, C_INT4, # Use a signed long, not the unsigned one used by the rest of the ZIP spec.
387
389
  ]
390
+ # The atime and ctime can be omitted if not present
388
391
  pack_array(data_and_packspecs)
389
392
  end
390
393
 
394
+ # Since we do not supply atime or ctime, the contents of the two extra fields (central dir and local header)
395
+ # is exactly the same, so we can use a method alias.
396
+ alias_method :timestamp_extra_for_central_directory_entry, :timestamp_extra_for_local_file_header
397
+
391
398
  # Writes the Zip64 extra field for the central directory header.It differs from the extra used in the local file header because it
392
399
  # also contains the location of the local file header in the ZIP as an 8-byte int.
393
400
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zip_tricks
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-09 00:00:00.000000000 Z
11
+ date: 2020-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -274,8 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
274
  - !ruby/object:Gem::Version
275
275
  version: '0'
276
276
  requirements: []
277
- rubyforge_project:
278
- rubygems_version: 2.6.11
277
+ rubygems_version: 3.0.3
279
278
  signing_key:
280
279
  specification_version: 4
281
280
  summary: Stream out ZIP files from Ruby