Fix ValueError when exported files have wrong mtime (#1666)

* Fix ValueError when exported files have wrong mtime

Set the `strict_timestamps` argument to `False`, so the media files which have a wrong mtime can be normally added to the zipfile.

* Update CONTRIBUTORS (ankitects#1666)

* Reformat exporting.py
This commit is contained in:
gnnoh 2022-02-16 09:17:20 +08:00 committed by GitHub
parent 94846dc4e3
commit d29a0beb40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -94,6 +94,7 @@ Spooghetti420 <github.com/spooghetti420>
Danish Prakash <github.com/danishprakash>
Araceli Yanez <github.com/aracelix>
Sam Bradshaw <samjr.bradshaw@gmail.com>
gnnoh <gerongfenh@gmail.com>
********************

View file

@ -340,7 +340,9 @@ class AnkiPackageExporter(AnkiExporter):
def exportInto(self, path: str) -> None:
# open a zip file
z = zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED, allowZip64=True)
z = zipfile.ZipFile(
path, "w", zipfile.ZIP_DEFLATED, allowZip64=True, strict_timestamps=False
)
media = self.doExport(z, path)
# media map
z.writestr("media", json.dumps(media))