[pp:ugoira] update mtime of zipped files (#6147)
in zip archives generated by '"mode": "archive"'
This commit is contained in:
@@ -253,18 +253,30 @@ class UgoiraPP(PostProcessor):
|
|||||||
self.delete = False
|
self.delete = False
|
||||||
if self.metadata:
|
if self.metadata:
|
||||||
with zipfile.ZipFile(pathfmt.temppath, "a") as zfile:
|
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)
|
fp.write(framedata)
|
||||||
else:
|
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:
|
with zipfile.ZipFile(pathfmt.realpath, "w") as zfile:
|
||||||
for frame in frames:
|
for frame in frames:
|
||||||
zinfo = zipfile.ZipInfo.from_file(
|
zinfo = zipfile.ZipInfo.from_file(
|
||||||
frame["path"], frame["file"])
|
frame["path"], frame["file"])
|
||||||
|
if self.mtime:
|
||||||
|
zinfo.date_time = mtime
|
||||||
with open(frame["path"], "rb") as src, \
|
with open(frame["path"], "rb") as src, \
|
||||||
zfile.open(zinfo, "w") as dst:
|
zfile.open(zinfo, "w") as dst:
|
||||||
shutil.copyfileobj(src, dst, 1024*8)
|
shutil.copyfileobj(src, dst, 1024*8)
|
||||||
if self.metadata:
|
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)
|
fp.write(framedata)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user