If no atime was specified (for example, when extracting from ustar
archives), set atime == mtime. Before this, atime would get restored to 0.
This commit is contained in:
parent
9aa98a5913
commit
9cfec77e7e
@ -1625,6 +1625,11 @@ set_time(struct archive_write_disk *a)
|
||||
times[0].tv_sec = archive_entry_atime(a->entry);
|
||||
times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000;
|
||||
|
||||
/* If no atime was specified, use mtime instead. */
|
||||
if (times[0].tv_sec == 0 && times[0].tv_usec == 0) {
|
||||
times[0].tv_sec = times[1].tv_sec;
|
||||
times[0].tv_usec = times[1].tv_usec;
|
||||
}
|
||||
#ifdef HAVE_FUTIMES
|
||||
if (a->fd >= 0 && futimes(a->fd, times) == 0) {
|
||||
return (ARCHIVE_OK);
|
||||
|
@ -63,6 +63,7 @@ static void create_reg_file(struct archive_entry *ae, const char *msg)
|
||||
|
||||
/* Write the entry to disk. */
|
||||
assert((ad = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
|
||||
failure("%s", msg);
|
||||
/*
|
||||
* A touchy API design issue: archive_write_data() does (as of
|
||||
@ -82,6 +83,7 @@ static void create_reg_file(struct archive_entry *ae, const char *msg)
|
||||
* the entry being a maximum size.
|
||||
*/
|
||||
archive_entry_set_size(ae, sizeof(data));
|
||||
archive_entry_set_mtime(ae, 123456789, 0);
|
||||
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
|
||||
assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
|
||||
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
|
||||
@ -95,7 +97,10 @@ static void create_reg_file(struct archive_entry *ae, const char *msg)
|
||||
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
|
||||
st.st_mode, archive_entry_mode(ae));
|
||||
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
|
||||
assertEqualInt(st.st_size, sizeof(data));
|
||||
failure("Old bug: if no atime specified, atime got set to Jan 1, 1970");
|
||||
assert(st.st_atime != 0);
|
||||
assertEqualInt(st.st_size, sizeof(data));
|
||||
assertEqualInt(st.st_mtime, 123456789);
|
||||
}
|
||||
|
||||
static void create_reg_file2(struct archive_entry *ae, const char *msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user