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

Sure. Starting with a file where the seconds field of the modification time is an odd number.

$ stat abc | grep Mod Modify: 2017-01-09 15:41:05.405778746 +0000

Now add that file into a zip archive.

$ perl -M'IO::Compress::Zip qw(zip)' -e ' zip "abc" => "abc.zip" '

unzip in a different directory

$ cd out $ unzip ../abc.zip

And stat the uncompressed file

$ stat abc | grep Mod Modify: 2017-01-09 15:41:05.000000000 +0000

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

    (++ for the sample). Interestingly, I see the other reported behaviour where the mtime is rounded down to even seconds:

    $ echo foo > abc $ stat abc | grep Mod Modify: 2017-01-11 09:47:51.022907652 +0000 $ perl -M'IO::Compress::Zip qw(zip)' -e ' zip "abc" => "abc.zip" ' $ mkdir out $ cd out $ unzip ../abc.zip Archive: ../abc.zip inflating: abc $ stat abc | grep Mod Modify: 2017-01-11 09:47:50.000000000 +0000

    Versions are:

    • Perl 5.20.3
    • IO::Compress::Zip 2.068
    • FS: ext2
    • zlib 1.2.8-7

    And this from "unzip -v":

    UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. +Send bug reports using http://www.info-zip.org/zip-bug.html; see README for + details. Latest sources and executables are at ftp://ftp.info-zip.org/pub/infoz +ip/ ; see ftp://ftp.info-zip.org/pub/infozip/UnZip.html for other sites. Compiled with gcc 5.0.0 20150210 (Red Hat 5.0.0-0.11) for Unix (Linux +ELF) on Feb 11 2015. UnZip special compilation options: COPYRIGHT_CLEAN (PKZIP 0.9x unreducing method not supported) SET_DIR_ATTRIB SYMLINKS (symbolic links supported, if RTL and file system per +mit) TIMESTAMP UNIXBACKUP USE_EF_UT_TIME USE_UNSHRINK (PKZIP/Zip 1.x unshrinking method supported) USE_DEFLATE64 (PKZIP 4.x Deflate64(tm) supported) UNICODE_SUPPORT [wide-chars, char coding: UTF-8] (handle UTF-8 + paths) MBCS-support (multibyte character support, MB_CUR_MAX = 6) LARGE_FILE_SUPPORT (large files over 2 GiB supported) ZIP64_SUPPORT (archives using Zip64 for large files supported) USE_BZIP2 (PKZIP 4.6+, using bzip2 lib version 1.0.6, 6-Sept-2 +010) VMS_TEXT_CONV [decryption, version 2.11 of 05 Jan 2007] UnZip and ZipInfo environment options: UNZIP: [none] UNZIPOPT: [none] ZIPINFO: [none] ZIPINFOOPT: [none]

    I'm wondering if maybe it's something in the unzip. Is there a simple way to query the entries in the zipfile to see what its contents are to the resolution of seconds? (I never use zip/unzip so this is all beyond my realm)

      I think it's a bug in the unzip utility. Slackware has (prematurely?) enabled the -DIZ_HAVE_UXUIDGID option when compiling the package and this causes the breakage. The option does not show up on "unzip -v" either.

      In unzip60 sources, process.c:2909

      flags &= ~0x0ff; /* ignore any previous UNIX field */
      That results in dos time fields being used instead of unix. I have no idea if there's a bugreport or a fix available somewhere.

      Just my 10 min debug. HtH.

      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

        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.