mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
add upper bound to # of media files in single zip
This commit is contained in:
parent
c437a38446
commit
f3f7835032
2 changed files with 3 additions and 2 deletions
|
@ -44,6 +44,7 @@ MODEL_CLOZE = 1
|
||||||
# deck schema & syncing vars
|
# deck schema & syncing vars
|
||||||
SCHEMA_VERSION = 11
|
SCHEMA_VERSION = 11
|
||||||
SYNC_ZIP_SIZE = int(2.5*1024*1024)
|
SYNC_ZIP_SIZE = int(2.5*1024*1024)
|
||||||
|
SYNC_ZIP_COUNT = 300
|
||||||
SYNC_URL = os.environ.get("SYNC_URL") or "https://ankiweb.net/sync/"
|
SYNC_URL = os.environ.get("SYNC_URL") or "https://ankiweb.net/sync/"
|
||||||
SYNC_VER = 5
|
SYNC_VER = 5
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ If the same name exists, compare checksums."""
|
||||||
# and place a json file in the zip with the necessary information.
|
# and place a json file in the zip with the necessary information.
|
||||||
|
|
||||||
def zipAdded(self):
|
def zipAdded(self):
|
||||||
"Add files to a zip until over SYNC_ZIP_SIZE. Return zip data."
|
"Add files to a zip until over SYNC_ZIP_SIZE/COUNT. Return zip data."
|
||||||
f = StringIO()
|
f = StringIO()
|
||||||
z = zipfile.ZipFile(f, "w", compression=zipfile.ZIP_DEFLATED)
|
z = zipfile.ZipFile(f, "w", compression=zipfile.ZIP_DEFLATED)
|
||||||
sz = 0
|
sz = 0
|
||||||
|
@ -330,7 +330,7 @@ If the same name exists, compare checksums."""
|
||||||
z.write(fname, str(cnt))
|
z.write(fname, str(cnt))
|
||||||
files[str(cnt)] = fname
|
files[str(cnt)] = fname
|
||||||
sz += os.path.getsize(fname)
|
sz += os.path.getsize(fname)
|
||||||
if sz > SYNC_ZIP_SIZE:
|
if sz > SYNC_ZIP_SIZE or cnt > SYNC_ZIP_COUNT:
|
||||||
break
|
break
|
||||||
cnt += 1
|
cnt += 1
|
||||||
z.writestr("_meta", json.dumps(files))
|
z.writestr("_meta", json.dumps(files))
|
||||||
|
|
Loading…
Reference in a new issue