Skip to content

Commit

Permalink
Report correct time stamps, even when ignoring them and also ignore t…
Browse files Browse the repository at this point in the history
…hem when comparing directories.
  • Loading branch information
dillof committed Jun 20, 2024
1 parent 277e4c3 commit 7a734f6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion regress/zipcmp_zip_dir.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion regress/zipcmp_zip_dir_slash.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 2 additions & 7 deletions src/zipcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 7a734f6

Please sign in to comment.