mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
option to disable media sync
This commit is contained in:
parent
7a71a0798c
commit
e03b51fae8
3 changed files with 19 additions and 4 deletions
|
@ -190,6 +190,8 @@ Are you sure?"""):
|
|||
self.activateWindow()
|
||||
self.raise_()
|
||||
# maybe sync (will load DB)
|
||||
self.pm.profile['syncMedia'] = False
|
||||
self.pm.save()
|
||||
self.onSync(auto=True)
|
||||
# skip the reset step; open overview directly
|
||||
self.moveToState("overview")
|
||||
|
|
|
@ -51,6 +51,7 @@ profileConf = dict(
|
|||
|
||||
# syncing
|
||||
syncKey=None,
|
||||
syncMedia=True,
|
||||
proxyHost='',
|
||||
proxyPass='',
|
||||
proxyPort=8080,
|
||||
|
|
20
aqt/sync.py
20
aqt/sync.py
|
@ -8,7 +8,7 @@ from anki import Collection
|
|||
from anki.sync import Syncer, RemoteServer, FullSyncer, MediaSyncer, \
|
||||
RemoteMediaServer
|
||||
from anki.hooks import addHook, removeHook
|
||||
from aqt.utils import tooltip, askUserDialog
|
||||
from aqt.utils import tooltip, askUserDialog, showWarning
|
||||
|
||||
# Sync manager
|
||||
######################################################################
|
||||
|
@ -40,7 +40,8 @@ class SyncManager(QObject):
|
|||
gc.collect()
|
||||
# create the thread, setup signals and start running
|
||||
t = self.thread = SyncThread(
|
||||
self.pm.collectionPath(), self.pm.profile['syncKey'], auth)
|
||||
self.pm.collectionPath(), self.pm.profile['syncKey'],
|
||||
auth=auth, media=self.pm.profile['syncMedia'])
|
||||
print "created thread"
|
||||
self.connect(t, SIGNAL("event"), self.onEvent)
|
||||
self.mw.progress.start(immediate=True, label=_("Connecting..."))
|
||||
|
@ -66,7 +67,8 @@ class SyncManager(QObject):
|
|||
elif evt == "mediaSync":
|
||||
self.mw.progress.update(label="media: "+args[0])
|
||||
elif evt == "error":
|
||||
print "error occurred", args[0]
|
||||
showWarning(_("Syncing failed:\n%s")%
|
||||
self._rewriteError(args[0]))
|
||||
elif evt == "clockOff":
|
||||
print "clock is wrong"
|
||||
elif evt == "noChanges":
|
||||
|
@ -86,6 +88,13 @@ class SyncManager(QObject):
|
|||
else:
|
||||
print "unknown evt", evt
|
||||
|
||||
def _rewriteError(self, err):
|
||||
if "Errno 61" in err:
|
||||
return _("""\
|
||||
Couldn't connect to AnkiWeb. Please check your network connection \
|
||||
and try again.""")
|
||||
return err
|
||||
|
||||
def _getUserPass(self):
|
||||
d = QDialog(self.mw)
|
||||
d.setWindowTitle("Anki")
|
||||
|
@ -163,11 +172,12 @@ do you want to keep the AnkiWeb version, overwriting the version here?"""),
|
|||
|
||||
class SyncThread(QThread):
|
||||
|
||||
def __init__(self, path, hkey, auth=None):
|
||||
def __init__(self, path, hkey, auth=None, media=True):
|
||||
QThread.__init__(self)
|
||||
self.path = path
|
||||
self.hkey = hkey
|
||||
self.auth = auth
|
||||
self.media = media
|
||||
|
||||
def run(self):
|
||||
self.col = Collection(self.path)
|
||||
|
@ -241,6 +251,8 @@ class SyncThread(QThread):
|
|||
self._syncMedia()
|
||||
|
||||
def _syncMedia(self):
|
||||
if not self.media:
|
||||
return
|
||||
self.server = RemoteMediaServer(self.hkey, self.server.con)
|
||||
self.client = MediaSyncer(self.col, self.server)
|
||||
ret = self.client.sync(self.mediaUsn)
|
||||
|
|
Loading…
Reference in a new issue