Restoring from backup preserves original file datestamps.
This commit is contained in:
1 parent
02ec6c5a47
commit
0a658e1b2e
2 files changed
+12
No files matched your search
@@ -116,6 +116,7 @@ date of first contribution):
|
||||
* [Dominik Paľo](https://github.com/DominikPalo)
|
||||
* [Kelly Anderson](https://github.com/cbxbiker61)
|
||||
* [Jim Neill](https://github.com/jneilliii)
|
||||
* [Dustin Kerber](https://github.com/kerber)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -808,10 +808,21 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin,
|
||||
if callable(on_log_progress):
|
||||
on_log_progress("Unpacking backup to {}...".format(temp))
|
||||
abstemp = os.path.abspath(temp)
|
||||
dirs = {}
|
||||
for member in zip.infolist():
|
||||
abspath = os.path.abspath(os.path.join(temp, member.filename))
|
||||
if abspath.startswith(abstemp):
|
||||
d = member.date_time
|
||||
zip.extract(member, temp)
|
||||
date_time = time.mktime(d + (0, 0, -1))
|
||||
if (os.path.isdir(abspath)):
|
||||
dirs[abspath] = date_time
|
||||
else:
|
||||
os.utime(abspath, (date_time, date_time))
|
||||
# set time on folders
|
||||
for name in dirs:
|
||||
date_time = dirs[name]
|
||||
os.utime(name, (date_time, date_time))
|
||||
|
||||
# sanity check
|
||||
configfile = os.path.join(temp, "basedir", "config.yaml")
|
||||
|
||||
Reference in new issue
Block a user