libzip
libzip copied to clipboard
zipmerge modifies time of zipped files when merging zip
Describe the Bug
When zip A is merged into zip B, the dates of files in zip B are not the ones of files in zip A.
It may be related to time zones.
Expected Behavior
Date of zipped files should not be modified when merging zips.
To Reproduce
Script to reproduce:
#! /usr/bin/env bash
export LANG='C.UTF-8'
export TZ='Europe/Paris'
touch --date='2006-03-04T18:12:49' test.txt
zip test.zip test.txt
zipmerge merge.zip test.zip
export TZ='UTC'
printf 'filesystem: '
stat --printf='%y %n\n' test.txt
printf 'test.zip: '
7z l test.zip | grep test.txt
printf 'merge.zip: '
7z l merge.zip | grep test.txt
The script creates a test.txt
file on filesystem with a given non-UTC date, then adds it to a test.zip
archive with zip
, then merges test.zip
into merge.zip
, then prints date of test.txt
on filesystem, in test.zip
and in merge.zip
.
Output:
updating: test.txt (stored 0%)
filesystem: 2006-03-04 17:12:49.000000000 +0000 test.txt
test.zip: 2006-03-04 17:12:49 ..... 0 0 test.txt
merge.zip: 2006-03-04 18:12:50 ..... 0 0 test.txt
The time of the file is 1 hour and 1 second off once merged.
libzip Version
57f5769d972519ffd0fe42e401fcdab87fdbf2a2
Operating System
$ lsb_release -d
Description: Ubuntu 21.10
$ gcc -v 2>&1 | egrep '^gcc version'
gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)