[postprocessor:zip] defer zip file creation (fixes #968)

don't try to create zip files on postprocessor construction,
wait until directory creation during file download,
This commit is contained in:
Mike Fährmann
2020-08-31 21:53:18 +02:00
parent 33fe67b594
commit fd0685d9b5
4 changed files with 25 additions and 20 deletions

View File

@@ -33,23 +33,23 @@ class ZipPP(PostProcessor):
algorithm)
algorithm = "store"
self.zfile = None
self.path = job.pathfmt.realdirectory
args = (self.path[:-1] + ext, "a",
self.COMPRESSION_ALGORITHMS[algorithm], True)
self.args = (self.path[:-1] + ext, "a",
self.COMPRESSION_ALGORITHMS[algorithm], True)
if options.get("mode") == "safe":
self.run = self._write_safe
self.zfile = None
self.args = args
else:
self.run = self._write
self.zfile = zipfile.ZipFile(*args)
def _write(self, pathfmt, zfile=None):
# 'NameToInfo' is not officially documented, but it's available
# for all supported Python versions and using it directly is a lot
# faster than calling getinfo()
if zfile is None:
if self.zfile is None:
self.zfile = zipfile.ZipFile(*self.args)
zfile = self.zfile
if pathfmt.filename not in zfile.NameToInfo:
zfile.write(pathfmt.temppath, pathfmt.filename)