Consistency with zip_close: zip_file_set_mtime wins over mtime from source.
Fixes #146
diff --git a/lib/zip_stat_index.c b/lib/zip_stat_index.c
index d19e76a..66b7661 100644
--- a/lib/zip_stat_index.c
+++ b/lib/zip_stat_index.c
@@ -48,10 +48,17 @@
if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) {
- if (zip_source_stat(za->entry[index].source, st) < 0) {
+ zip_entry_t *entry = za->entry+index;
+
+ if (zip_source_stat(entry->source, st) < 0) {
zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
return -1;
}
+
+ if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
+ st->mtime = de->last_mod;
+ st->valid |= ZIP_STAT_MTIME;
+ }
}
else {
zip_stat_init(st);