This commit is contained in:
Soren I. Bjornstad 2013-12-12 17:33:32 -06:00
commit aef9fa630f
7 changed files with 26 additions and 14 deletions

View file

@ -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

View file

@ -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"]

View file

@ -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))

View file

@ -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(

View file

@ -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</button>''' % (
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. \

View file

@ -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
######################################################################

View file

@ -349,6 +349,13 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="compressBackups">
<property name="text">
<string>Compress backups (slower)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="openBackupFolder">
<property name="text">