Restore compression of SVG files on export

This commit is contained in:
Self-Perfection 2016-09-02 13:59:22 +03:00
parent 72f128156e
commit a5b0852360

View File

@ -266,14 +266,7 @@ class AnkiPackageExporter(AnkiExporter):
z.write(colfile, "collection.anki2") z.write(colfile, "collection.anki2")
# and media # and media
self.prepareMedia() self.prepareMedia()
media = {} media = self._exportMedia(z, self.mediaFiles, self.mediaDir)
for c, file in enumerate(self.mediaFiles):
cStr = str(c)
mpath = os.path.join(self.mediaDir, file)
if os.path.exists(mpath):
z.write(mpath, cStr, zipfile.ZIP_STORED)
media[cStr] = file
runHook("exportedMediaFiles", c)
# tidy up intermediate files # tidy up intermediate files
os.unlink(colfile) os.unlink(colfile)
p = path.replace(".apkg", ".media.db2") p = path.replace(".apkg", ".media.db2")
@ -292,12 +285,18 @@ class AnkiPackageExporter(AnkiExporter):
# copy all media # copy all media
if not self.includeMedia: if not self.includeMedia:
return {} return {}
media = {}
mdir = self.col.media.dir() mdir = self.col.media.dir()
for c, file in enumerate(os.listdir(mdir)): return self._exportMedia(z, os.listdir(mdir), mdir)
def _exportMedia(self, z, files, fdir):
media = {}
for c, file in enumerate(files):
cStr = str(c) cStr = str(c)
mpath = os.path.join(mdir, file) mpath = os.path.join(fdir, file)
if os.path.exists(mpath): if os.path.exists(mpath):
if re.search('\.svg$', file, re.IGNORECASE):
z.write(mpath, cStr, zipfile.ZIP_DEFLATED)
else:
z.write(mpath, cStr, zipfile.ZIP_STORED) z.write(mpath, cStr, zipfile.ZIP_STORED)
media[cStr] = file media[cStr] = file
runHook("exportedMediaFiles", c) runHook("exportedMediaFiles", c)