From 7a734f63e3f4c6401ecb52bb33081c2082ef525e Mon Sep 17 00:00:00 2001 From: Dieter Baron Date: Thu, 20 Jun 2024 10:31:20 +0200 Subject: [PATCH] Report correct time stamps, even when ignoring them and also ignore them when comparing directories. --- regress/zipcmp_zip_dir.test | 2 +- regress/zipcmp_zip_dir_slash.test | 2 +- src/zipcmp.c | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/regress/zipcmp_zip_dir.test b/regress/zipcmp_zip_dir.test index 33e91588b..e1be26349 100644 --- a/regress/zipcmp_zip_dir.test +++ b/regress/zipcmp_zip_dir.test @@ -11,7 +11,7 @@ stdout --- zipcmp_zip_dir.zip +++ a - directory '00-empty-dir/' -- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 0 +- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 1610623116 + directory 'empty-dir-in-dir/' - directory 'empty-dir/' end-of-inline-data diff --git a/regress/zipcmp_zip_dir_slash.test b/regress/zipcmp_zip_dir_slash.test index 5b8f8d664..1191e4f5b 100644 --- a/regress/zipcmp_zip_dir_slash.test +++ b/regress/zipcmp_zip_dir_slash.test @@ -11,7 +11,7 @@ stdout --- zipcmp_zip_dir.zip +++ a/ - directory '00-empty-dir/' -- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 0 +- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 1610623116 + directory 'empty-dir-in-dir/' - directory 'empty-dir/' end-of-inline-data diff --git a/src/zipcmp.c b/src/zipcmp.c index 7f38388d7..39ab20969 100644 --- a/src/zipcmp.c +++ b/src/zipcmp.c @@ -568,12 +568,7 @@ list_zip(const char *name, struct archive *a) { a->entry[i].comp_method = 0; a->entry[i].n_extra_fields = 0; } - if (compare_time_stamps) { - a->entry[i].last_modification_time = st.mtime; - } - else { - a->entry[i].last_modification_time = 0; - } + a->entry[i].last_modification_time = st.mtime; } if (paranoid) { @@ -755,7 +750,7 @@ entry_cmp(const void *p1, const void *p2) { if (e1->crc != e2->crc) { return (int)e1->crc - (int)e2->crc; } - if (e1->last_modification_time != e2->last_modification_time) { + if (compare_time_stamps && e1->last_modification_time != e2->last_modification_time) { return (int)(e1->last_modification_time - e2->last_modification_time); }