diff --git a/Makefile b/Makefile index 011f95be1..ecc2910bc 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,8 @@ install: cp -av * ${DESTDIR}${PREFIX}/share/anki/ cd ${DESTDIR}${PREFIX}/share/anki && (\ mv runanki ${DESTDIR}${PREFIX}/local/bin/anki;\ - mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\ + test -d ${DESTDIR}${PREFIX}/share/pixmaps &&\ + mv anki.xpm anki.png ${DESTDIR}${PREFIX}/share/pixmaps/;\ mv anki.desktop ${DESTDIR}${PREFIX}/share/applications;\ mv anki.1 ${DESTDIR}${PREFIX}/share/man/man1/) xdg-mime install anki.xml --novendor @@ -23,7 +24,8 @@ install: uninstall: rm -rf ${DESTDIR}${PREFIX}/share/anki rm -rf ${DESTDIR}${PREFIX}/local/bin/anki - rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.{xpm,png} + rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.xpm + rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.png rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop rm -rf ${DESTDIR}${PREFIX}/share/man/man1/anki.1 -xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml diff --git a/anki/__init__.py b/anki/__init__.py index c45d39df6..b54587f97 100644 --- a/anki/__init__.py +++ b/anki/__init__.py @@ -30,6 +30,6 @@ if arch[1] == "ELF": sys.path.insert(0, os.path.join(ext, "py2.%d-%s" % ( sys.version_info[1], arch[0][0:2]))) -version="2.0.18" # build scripts grep this line, so preserve formatting +version="2.0.19" # build scripts grep this line, so preserve formatting from anki.storage import Collection __all__ = ["Collection"] diff --git a/anki/media.py b/anki/media.py index b30234665..9826ae6f1 100644 --- a/anki/media.py +++ b/anki/media.py @@ -373,7 +373,7 @@ class MediaManager(object): z.write(fname, str(cnt)) files[str(cnt)] = unicodedata.normalize("NFC", fname) sz += os.path.getsize(fname) - if sz > SYNC_ZIP_SIZE or cnt > SYNC_ZIP_COUNT: + if sz >= SYNC_ZIP_SIZE or cnt >= SYNC_ZIP_COUNT: break cnt += 1 z.writestr("_meta", json.dumps(files)) diff --git a/anki/sync.py b/anki/sync.py index 39d7387af..eb48fd591 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -3,7 +3,6 @@ # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import urllib -import os import sys import gzip import random @@ -16,6 +15,7 @@ from anki.consts import * from hooks import runHook import anki + # syncing vars HTTP_TIMEOUT = 90 HTTP_PROXY = None @@ -750,8 +750,8 @@ class MediaSyncer(object): # step 5: sanity check during beta testing # NOTE: when removing this, need to move server tidyup # back from sanity check to addFiles - s = self.server.mediaSanity() c = self.mediaSanity() + s = self.server.mediaSanity(client=c) self.col.log("mediaSanity", c, s) if c != s: # if the sanity check failed, force a resync @@ -797,9 +797,9 @@ class RemoteMediaServer(HttpSyncer): return json.loads( self.req("addFiles", StringIO(zip), comp=0)) - def mediaSanity(self): + def mediaSanity(self, **kw): return json.loads( - self.req("mediaSanity")) + self.req("mediaSanity", StringIO(json.dumps(kw)))) def mediaList(self): return json.loads( diff --git a/aqt/main.py b/aqt/main.py index 63fee896f..4e89481f6 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -2,10 +2,7 @@ # -*- coding: utf-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import os -import sys import re -import traceback import signal import zipfile @@ -13,7 +10,6 @@ from send2trash import send2trash from aqt.qt import * from anki import Collection from anki.utils import isWin, isMac, intTime, splitFields, ids2str - from anki.hooks import runHook, addHook import aqt import aqt.progress @@ -25,6 +21,7 @@ from aqt.utils import restoreGeom, showInfo, showWarning,\ openHelp, openLink, checkInvalidFilename import anki.db + class AnkiQt(QMainWindow): def __init__(self, app, profileManager, args): QMainWindow.__init__(self) @@ -325,6 +322,10 @@ the manual for information on how to restore from an automatic backup.")) def backup(self): nbacks = self.pm.profile['numBackups'] + if self.pm.profile.get('compressBackups', True): + zipStorage = zipfile.ZIP_DEFLATED + else: + zipStorage = zipfile.ZIP_STORED if not nbacks or os.getenv("ANKIDEV", 0): return dir = self.pm.backupFolder() @@ -345,7 +346,7 @@ the manual for information on how to restore from an automatic backup.")) n = backups[-1][0] + 1 # do backup newpath = os.path.join(dir, "backup-%d.apkg" % n) - z = zipfile.ZipFile(newpath, "w", zipfile.ZIP_DEFLATED) + z = zipfile.ZipFile(newpath, "w", zipStorage) z.write(path, "collection.anki2") z.writestr("media", "{}") z.close() @@ -825,7 +826,7 @@ title="%s">%s''' % ( aqt.update.showMessages(self, data) def clockIsOff(self, diff): - diffText = ngettext("%s second", "%s seconds", diff) + diffText = ngettext("%s second", "%s seconds", diff) % diff warn = _("""\ In order to ensure your collection works correctly when moved between \ devices, Anki requires your computer's internal clock to be set correctly. \ diff --git a/aqt/preferences.py b/aqt/preferences.py index 19d2c2ba6..1fc4465cd 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -112,6 +112,7 @@ Not currently enabled; click the sync button in the main window to enable.""")) def setupBackup(self): self.form.numBackups.setValue(self.prof['numBackups']) + self.form.compressBackups.setChecked(self.prof.get("compressBackups", True)) self.connect(self.form.openBackupFolder, SIGNAL("linkActivated(QString)"), self.onOpenBackup) @@ -121,6 +122,7 @@ Not currently enabled; click the sync button in the main window to enable.""")) def updateBackup(self): self.prof['numBackups'] = self.form.numBackups.value() + self.prof['compressBackups'] = self.form.compressBackups.isChecked() # Basic & Advanced Options ###################################################################### diff --git a/designer/preferences.ui b/designer/preferences.ui index 03b96e11f..186314b9a 100644 --- a/designer/preferences.ui +++ b/designer/preferences.ui @@ -349,6 +349,13 @@ + + + + Compress backups (slower) + + +