Commit 14cd430 1 parent 472c3ab commit 14cd430 Copy full SHA for 14cd430
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 @@ -1090,6 +1090,19 @@ def extract(self):
1090
1090
archive = handler_class (util .py3_path (self .toppath ), mode = 'r' )
1091
1091
try :
1092
1092
archive .extractall (extract_to )
1093
+
1094
+ # From here:
1095
+ # https://stackoverflow.com/questions/9813243/extract-files-from-zip-file-and-retain-mod-date
1096
+ # fixing #4392
1097
+
1098
+ for f in archive .infolist ():
1099
+ # path to this extracted f-item
1100
+ fullpath = os .path .join (extract_to , f .filename )
1101
+ # still need to adjust the dt o/w item will have the current dt
1102
+ date_time = time .mktime (f .date_time + (0 , 0 , - 1 ))
1103
+ # update date_time
1104
+ os .utime (fullpath , (date_time , date_time ))
1105
+
1093
1106
finally :
1094
1107
archive .close ()
1095
1108
self .extracted = True
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ New features:
32
32
* :ref: `import-options `: Add support for re-running the importer on paths in
33
33
log files that were created with the ``-l `` (or ``--logfile ``) argument.
34
34
:bug: `4379 ` :bug: `4387 `
35
+ * Preserve mtimes from archives
36
+ :bug: `4392 `
35
37
36
38
Bug fixes:
37
39
You can’t perform that action at this time.
0 commit comments