Internal TC unzip doesn't preserve timestamps for directories

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Internal TC unzip doesn't preserve timestamps for directories

Post by *Usher »

1. Download the following zip archive: https://1drv.ms/u/s!Aqm4ZaWdL2tfgk34ukpfUevAaQZ_?e=KL2JZO
2. Open it (f.e. with Ctrl+PgDn) and note timestamps shown for directories. You should see date 2020-02-25.
3. Unzip the archive with TC internal unzip. You can use Alt+F9 outside of the archive or F5 inside the archive. Now you should see that unpacked directories have current date set.

Tested in TC 32-bit version 9.51 and 10.0b7 on NTFS file system.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
petermad
Power Member
Power Member
Posts: 14700
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *petermad »

2Usher
I can confirm it with your file from https://1drv.ms/u/s!Aqm4ZaWdL2tfgk34ukpfUevAaQZ_?e=KL2JZO - but I cannot confirm it with other zip files, that I have available,

I can add that if I unpack your file with 7zip or WinRar, they do not preserve the dir dates either - and with these two packers, not even the base dir (xharbour) has the correct date - at least TC sets the base dir's date correct (as TC also does if you unpack a subdir).

So I is more your zip file that has a problem, than TC / 7zip /WinRar

EDIT:
I have repacked your file here: https://madsenworld.dk/tcmd/dir_timestamp.xhb10264_src.zip - with this file the timestamps of the directories are preserved.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *Usher »

2petermad
Well, it's not MY zip (neither file nor zip utility), I have downloaded that file. It seems to not have directory names in the archive central directory. and I think I can recreate such an archive on my own with 7zip:
Change unpacked directory timestamps to 2020-02-25, then use the following command:

Code: Select all

7z a archive *.* -r -tzip
The error comes from using *.* instead of * as wildcard.

When browsing the archive, the directory names are restored from file paths and timestamps are restored form the first file which uses the directory name in path. You can check it when browsing the archive with sort order set to unsorted (Ctrl+F7). The unpacker can use the same rule to restore timestamps.

I suspect, that you can download such files (or even worse) on many sites. There are even worse cases - some stupid server-side utils create zip files with NO timestamps saved for any file at all.
petermad wrote: 2021-04-25, 19:58 UTC 2Usher
I can add that if I unpack your file with 7zip or WinRar, they do not preserve the dir dates either - and with these two packers, not even the base dir (xharbour) has the correct date - at least TC sets the base dir's date correct (as TC also does if you unpack a subdir).
TC sets the base dir date correct only when you use F5 inside archive, with Alt+F9 outside it's also current timestamp.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
petermad
Power Member
Power Member
Posts: 14700
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *petermad »

The error comes from using *.* instead of * as wildcard.
OK - that must be the reason.

First I thought it was because there were timestamps with uneven seconds in the archive - When I pack with TC's internal Zip packer, uneven seconds are converted to even. But I also tried packing the files in "xharbour" with 7Zip and WinRar (both in zip format) which preserve the uneven seconds - and TC also unpack these archives correct.

But anyway - it is not a TC bug.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *Usher »

petermad wrote: 2021-04-25, 21:26 UTCFirst I thought it was because there were timestamps with uneven seconds in the archive
It's for DOS compatibility kept by the original ZIP specification. There's still a problem with rounding seconds, as I have remarked here:
viewtopic.php?f=14&t=50434&p=360394#p360394
petermad wrote: 2021-04-25, 21:26 UTCBut anyway - it is not a TC bug.
It's a problem with zip lib used by TC. But TC itself can display better timestamps so it is capable to change them when unpacking is finished. I think this topic should be moved to TC suggestions.
Andrzej P. Wozniak
Polish subforum moderator
User avatar
Dalai
Power Member
Power Member
Posts: 9352
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *Dalai »

It's the same thing again: The directories themselves are not packed into the ZIP file. Instead, relative paths are created in the archive. You can see this with InfoZip's unzip utility where the directories in the archive don't have their own line listed. This is also why you can't find "cgi" directory within that archive using TC's search function, although it's listed in the panel alright. After extracting it can be found no problem. In short: TC is somewhat limited when it comes to such archives.

BTW, one funny thing: When extracting the archive with F5, the first dir level gets 2020-02-25 while the directories below that get current time. When extracting the archive with AltF9, every directory gets current time.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48005
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *ghisler(Author) »

Yes, this is intentional: Total Commander only restores timestamps from folders which are explicitly stored in the zip. If there are only files with relative names, then TC shows the timestamp of the first file it encounters, which isn't really the timestamp of the folder. For example, if the zip contains
folder1\file1.ext
folder1\file2.ext
folder2\file3.ext

Then TC shows the timestamp of file1.ext for folder1, and the timestamp of file3.ext for folder2.
But these are NOT the original timestamps of folder1 and folder2! Therefore it makes no sense to restore them.

Total Commander itself and most ZIP packers like pkzip, winzip etc. do store the folders themselves in the ZIP archive, so their timestamps are preserved and can be unpacked.
Author of Total Commander
https://www.ghisler.com
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Internal TC unzip doesn't preserve timestamps for directories

Post by *Usher »

TC has an option to set ZIP date to newest file date - when packing. You can provide similar option to set dir date to newest file date if the dir date is current or newer (future timestamp, for example 2559-01-01 or so) - when unpacking.
Andrzej P. Wozniak
Polish subforum moderator
Post Reply