mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 13:47:13 -05:00
fix syncName before attempting to load the deck after a personal download
This commit is contained in:
parent
9923d0b2dc
commit
bddbb14340
1 changed files with 10 additions and 4 deletions
|
|
@ -14,9 +14,10 @@ QtConfig = pyqtconfig.Configuration()
|
||||||
from anki import DeckStorage
|
from anki import DeckStorage
|
||||||
from anki.errors import *
|
from anki.errors import *
|
||||||
from anki.sound import hasSound, playFromText, clearAudioQueue, stripSounds
|
from anki.sound import hasSound, playFromText, clearAudioQueue, stripSounds
|
||||||
from anki.utils import addTags, deleteTags, parseTags, canonifyTags, stripHTML
|
from anki.utils import addTags, deleteTags, parseTags, canonifyTags, \
|
||||||
|
stripHTML, checksum
|
||||||
from anki.media import rebuildMediaDir, downloadMissing
|
from anki.media import rebuildMediaDir, downloadMissing
|
||||||
from anki.db import OperationalError, SessionHelper
|
from anki.db import OperationalError, SessionHelper, sqlite
|
||||||
from anki.stdmodels import BasicModel
|
from anki.stdmodels import BasicModel
|
||||||
from anki.hooks import runHook, addHook, removeHook, _hooks, wrap
|
from anki.hooks import runHook, addHook, removeHook, _hooks, wrap
|
||||||
from anki.deck import newCardOrderLabels, newCardSchedulingLabels
|
from anki.deck import newCardOrderLabels, newCardSchedulingLabels
|
||||||
|
|
@ -2265,9 +2266,14 @@ Are you sure?""" % deckName),
|
||||||
p = os.path.join(self.documentDir, name + ".anki")
|
p = os.path.join(self.documentDir, name + ".anki")
|
||||||
shutil.copy2(self.deckPath, p)
|
shutil.copy2(self.deckPath, p)
|
||||||
self.deckPath = p
|
self.deckPath = p
|
||||||
|
# since we've moved the deck, we have to set sync path
|
||||||
|
# ourselves
|
||||||
|
c = sqlite.connect(p)
|
||||||
|
c.execute("update decks set syncName = ?",
|
||||||
|
[checksum(p.encode("utf-8"))])
|
||||||
|
c.commit()
|
||||||
|
c.close()
|
||||||
self.loadDeck(self.deckPath, sync=False)
|
self.loadDeck(self.deckPath, sync=False)
|
||||||
if self.loadAfterSync == 2:
|
|
||||||
self.deck.enableSyncing()
|
|
||||||
else:
|
else:
|
||||||
self.moveToState("noDeck")
|
self.moveToState("noDeck")
|
||||||
self.deckPath = None
|
self.deckPath = None
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue