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