File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1122,6 +1122,19 @@ def extract(self):
1122
1122
archive = handler_class (util .py3_path (self .toppath ), mode = 'r' )
1123
1123
try :
1124
1124
archive .extractall (extract_to )
1125
+
1126
+ # Adjust the files' mtimes to match the information from the
1127
+ # archive. Inspired by: https://stackoverflow.com/q/9813243
1128
+ for f in archive .infolist ():
1129
+ # The date_time will need to adjusted otherwise
1130
+ # the item will have the current date_time of extraction.
1131
+ # The (0, 0, -1) is added to date_time because the
1132
+ # function time.mktime expects a 9-element tuple.
1133
+ # The -1 indicates that the DST flag is unknown.
1134
+ date_time = time .mktime (f .date_time + (0 , 0 , - 1 ))
1135
+ fullpath = os .path .join (extract_to , f .filename )
1136
+ os .utime (fullpath , (date_time , date_time ))
1137
+
1125
1138
finally :
1126
1139
archive .close ()
1127
1140
self .extracted = True
Original file line number Diff line number Diff line change @@ -52,6 +52,8 @@ New features:
52
52
* :ref: `import-options `: Add support for re-running the importer on paths in
53
53
log files that were created with the ``-l `` (or ``--logfile ``) argument.
54
54
:bug: `4379 ` :bug: `4387 `
55
+ * Preserve mtimes from archives
56
+ :bug: `4392 `
55
57
* Add :ref: `%sunique{} <sunique >` template to disambiguate between singletons.
56
58
:bug: `4438 `
57
59
* Add a new ``import.ignored_alias_types `` config option to allow for
You can’t perform that action at this time.
0 commit comments