[pp:ugoira] update mtime of zipped files (#6147)

in zip archives generated by '"mode": "archive"'
pull/4791/merge
Mike Fährmann 1 week ago
parent df0d7d4a12
commit 319116c923
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -253,18 +253,30 @@ class UgoiraPP(PostProcessor):
self.delete = False
if self.metadata:
with zipfile.ZipFile(pathfmt.temppath, "a") as zfile:
with zfile.open(metaname, "w") as fp:
zinfo = zipfile.ZipInfo(metaname)
if self.mtime:
zinfo.date_time = zfile.infolist()[0].date_time
with zfile.open(zinfo, "w") as fp:
fp.write(framedata)
else:
if self.mtime:
dt = pathfmt.kwdict["date_url"] or pathfmt.kwdict["date"]
mtime = (dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second)
with zipfile.ZipFile(pathfmt.realpath, "w") as zfile:
for frame in frames:
zinfo = zipfile.ZipInfo.from_file(
frame["path"], frame["file"])
if self.mtime:
zinfo.date_time = mtime
with open(frame["path"], "rb") as src, \
zfile.open(zinfo, "w") as dst:
shutil.copyfileobj(src, dst, 1024*8)
if self.metadata:
with zfile.open(metaname, "w") as fp:
zinfo = zipfile.ZipInfo(metaname)
if self.mtime:
zinfo.date_time = mtime
with zfile.open(zinfo, "w") as fp:
fp.write(framedata)
return True

Loading…
Cancel
Save