in reply to Re^10: Archive::Zip Modify Date Oddity
in thread Archive::Zip Modify Date Oddity

I'm running exactly the same version of unzip & it works fine. To get more details on the zip file, try running

zipinfo -v abc.zip

See my first reply dated today for what you need to look for in the output.

Also - IO:Compress comes with a script called zipdetails that dumps lots of details on the fip file. If you happen to have available that try running this. The thing to look for is the "Extended Timestamp" entry

$ zipdetails abc.zip 0000 LOCAL HEADER #1 04034B50 0004 Extract Zip Spec 14 '2.0' 0005 Extract OS 00 'MS-DOS' 0006 General Purpose Flag 0008 [Bits 1-2] 0 'Normal Compression' [Bit 3] 1 'Streamed' 0008 Compression Method 0008 'Deflated' 000A Last Mod Time 4A2B4C89 'Wed Jan 11 09:36:18 2017' 000E CRC 00000000 0012 Compressed Length 00000000 0016 Uncompressed Length 00000000 001A Filename Length 0003 001C Extra Length 001C 001E Filename 'abc' 0021 Extra ID #0001 5455 'UT: Extended Timestamp' 0023 Length 0009 0025 Flags '03 mod access' 0026 Mod Time 5875FC93 'Wed Jan 11 09:36:19 2017' 002A Access Time 5875FCA7 'Wed Jan 11 09:36:39 2017' 002E Extra ID #0002 7875 'ux: Unix Extra Type 3' 0030 Length 000B 0032 Version 01 0033 UID Size 04 0034 UID 0000245B 0038 GID Size 04 0039 GID 00005208 003D PAYLOAD KLJ... 0043 STREAMING DATA HEADER 08074B50 0047 CRC 4788814E 004B Compressed Length 00000006 004F Uncompressed Length 00000004 0053 CENTRAL HEADER #1 02014B50 0057 Created Zip Spec 14 '2.0' 0058 Created OS 03 'Unix' 0059 Extract Zip Spec 14 '2.0' 005A Extract OS 00 'MS-DOS' 005B General Purpose Flag 0008 [Bits 1-2] 0 'Normal Compression' [Bit 3] 1 'Streamed' 005D Compression Method 0008 'Deflated' 005F Last Mod Time 4A2B4C89 'Wed Jan 11 09:36:18 2017' 0063 CRC 4788814E 0067 Compressed Length 00000006 006B Uncompressed Length 00000004 006F Filename Length 0003 0071 Extra Length 0018 0073 Comment Length 0000 0075 Disk Start 0000 0077 Int File Attributes 0001 [Bit 0] 1 Text Data 0079 Ext File Attributes 81A40000 007D Local Header Offset 00000000 0081 Filename 'abc' 0084 Extra ID #0001 5455 'UT: Extended Timestamp' 0086 Length 0005 0088 Flags '01 mod' 0089 Mod Time 5875FC93 'Wed Jan 11 09:36:19 2017' 008D Extra ID #0002 7875 'ux: Unix Extra Type 3' 008F Length 000B 0091 Version 01 0092 UID Size 04 0093 UID 0000245B 0097 GID Size 04 0098 GID 00005208 009C END CENTRAL HEADER 06054B50 00A0 Number of this disk 0000 00A2 Central Dir Disk no 0000 00A4 Entries in this disk 0001 00A6 Total Entries 0001 00A8 Size of Central Dir 00000049 00AC Offset to Central Dir 00000053 00B0 Comment Length 0000 Done

Replies are listed 'Best First'.
Re^12: Archive::Zip Modify Date Oddity
by hippo (Archbishop) on Jan 11, 2017 at 12:18 UTC

    Very interesting. Here's what zipinfo tells me:

    $ zipinfo -v abc.zip Archive: abc.zip There is no zipfile comment. End-of-central-directory record: ------------------------------- Zip archive file size: 178 (00000000000000B2h) Actual end-cent-dir record offset: 156 (000000000000009Ch) Expected end-cent-dir record offset: 156 (000000000000009Ch) (based on the length of the central directory and its expected offse +t) This zipfile constitutes the sole disk of a single-part archive; its central directory contains 1 entry. The central directory is 73 (0000000000000049h) bytes long, and its (expected) offset in bytes from the beginning of the zipfile is 83 (0000000000000053h). Central directory entry #1: --------------------------- abc offset of local header from start of archive: 0 (0000000000000000h) +bytes file system or operating system of origin: Unix version of encoding software: 2.0 minimum file system compatibility required: MS-DOS, OS/2 or NT F +AT minimum software version required to extract: 2.0 compression method: deflated compression sub-type (deflation): normal file security status: not encrypted extended local header: yes file last modified on (DOS date/time): 2017 Jan 11 09:47:50 file last modified on (UT extra field modtime): 2017 Jan 11 09:47:51 + local file last modified on (UT extra field modtime): 2017 Jan 11 09:47:51 + UTC 32-bit CRC value (hex): 7e3265a8 compressed size: 6 bytes uncompressed size: 4 bytes length of filename: 3 characters length of extra field: 24 bytes length of file comment: 0 characters disk number on which file begins: disk 1 apparent file type: text Unix file attributes (100664 octal): -rw-rw-r-- MS-DOS file attributes (00 hex): none The central-directory extra field contains: - A subfield with ID 0x5455 (universal time) and 5 data bytes. The local extra field has UTC/GMT modification time. - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data by +tes: 01 04 e8 03 00 00 04 e8 03 00 00. There is no file comment.

    So the "UT extra field modtime" entries are there and show the 1 second difference. I wonder why unzip isn't respecting that.

    Here's what I see from zipdetails:

    $ zipdetails abc.zip 0000 LOCAL HEADER #1 04034B50 0004 Extract Zip Spec 14 '2.0' 0005 Extract OS 00 'MS-DOS' 0006 General Purpose Flag 0008 [Bits 1-2] 0 'Normal Compression' [Bit 3] 1 'Streamed' 0008 Compression Method 0008 'Deflated' 000A Last Mod Time 4A2B4DF9 'Wed Jan 11 09:47:50 2017' 000E CRC 00000000 0012 Compressed Length 00000000 0016 Uncompressed Length 00000000 001A Filename Length 0003 001C Extra Length 001C 001E Filename 'abc' 0021 Extra ID #0001 5455 'UT: Extended Timestamp' 0023 Length 0009 0025 Flags '03 mod access' 0026 Mod Time 5875FF47 'Wed Jan 11 09:47:51 2017' 002A Access Time 5875FF47 'Wed Jan 11 09:47:51 2017' 002E Extra ID #0002 7875 'ux: Unix Extra Type 3' 0030 Length 000B 0032 Version 01 0033 UID Size 04 0034 UID 000003E8 0038 GID Size 04 0039 GID 000003E8 003D PAYLOAD K..... 0043 STREAMING DATA HEADER 08074B50 0047 CRC 7E3265A8 004B Compressed Length 00000006 004F Uncompressed Length 00000004 0053 CENTRAL HEADER #1 02014B50 0057 Created Zip Spec 14 '2.0' 0058 Created OS 03 'Unix' 0059 Extract Zip Spec 14 '2.0' 005A Extract OS 00 'MS-DOS' 005B General Purpose Flag 0008 [Bits 1-2] 0 'Normal Compression' [Bit 3] 1 'Streamed' 005D Compression Method 0008 'Deflated' 005F Last Mod Time 4A2B4DF9 'Wed Jan 11 09:47:50 2017' 0063 CRC 7E3265A8 0067 Compressed Length 00000006 006B Uncompressed Length 00000004 006F Filename Length 0003 0071 Extra Length 0018 0073 Comment Length 0000 0075 Disk Start 0000 0077 Int File Attributes 0001 [Bit 0] 1 Text Data 0079 Ext File Attributes 81B40000 007D Local Header Offset 00000000 0081 Filename 'abc' 0084 Extra ID #0001 5455 'UT: Extended Timestamp' 0086 Length 0005 0088 Flags '01 mod' 0089 Mod Time 5875FF47 'Wed Jan 11 09:47:51 2017' 008D Extra ID #0002 7875 'ux: Unix Extra Type 3' 008F Length 000B 0091 Version 01 0092 UID Size 04 0093 UID 000003E8 0097 GID Size 04 0098 GID 000003E8 009C END CENTRAL HEADER 06054B50 00A0 Number of this disk 0000 00A2 Central Dir Disk no 0000 00A4 Entries in this disk 0001 00A6 Total Entries 0001 00A8 Size of Central Dir 00000049 00AC Offset to Central Dir 00000053 00B0 Comment Length 0000 Done

    and again the correct times are present as the "Extended timestamp" entries. So inspection suggests that the zipfile is OK but unzip is ignoring the extended attributes.

      Output from zipinfo & zipdetails looks fine. You seem to have an identical version of unzip, so I'm struggling to explain why we don't get exactly the same bahavior when we unzip abc.zip.

      Here are a couple of tests to try.

      Can you try creating the zip file like this and see if the mod time is correct when you unzip it.

      perl -M'IO::Compress::Zip qw(zip)' -e ' zip "abc" => "abc.zip", Stream + => 0 '

      Also, try creating the zip file using the zip exe and see what the mod time looks like when unzipped.

      zip abc.zip abc

        Even with either of those it's still a 2-second resolution:

        $ perl -M'IO::Compress::Zip qw(zip)' -e ' zip "abc" => "abc2.zip", Str +eam => 0 ' $ cd out $ rm abc $ unzip ../abc2.zip Archive: ../abc2.zip inflating: abc $ stat abc | grep Mod Modify: 2017-01-11 09:47:50.000000000 +0000 $ rm abc $ cd .. $ zip abc3.zip abc adding: abc (stored 0%) $ cd out $ unzip ../abc3.zip Archive: ../abc3.zip extracting: abc $ stat abc | grep Mod Modify: 2017-01-11 09:47:52.000000000 +0000