diff --git a/anki/collection.py b/anki/collection.py index d54cdf932..a6abe04b6 100644 --- a/anki/collection.py +++ b/anki/collection.py @@ -171,7 +171,7 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""", self.load() self.lock() - def modSchema(self, check=True): + def modSchema(self, check): "Mark schema modified. Call this first so user can abort if necessary." if not self.schemaChanged(): if check and not runFilter("modSchema", True): @@ -197,7 +197,7 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""", self.models.beforeUpload() self.tags.beforeUpload() self.decks.beforeUpload() - self.modSchema() + self.modSchema(check=False) self.ls = self.scm # ensure db is compacted before upload self.db.execute("vacuum") diff --git a/anki/decks.py b/anki/decks.py index b939bd5e8..a09194fab 100644 --- a/anki/decks.py +++ b/anki/decks.py @@ -344,7 +344,7 @@ class DeckManager(object): def remConf(self, id): "Remove a configuration and update all decks using it." assert int(id) != 1 - self.col.modSchema() + self.col.modSchema(check=True) del self.dconf[str(id)] for g in self.all(): # ignore cram decks diff --git a/anki/models.py b/anki/models.py index 7f46b524b..bd363514b 100644 --- a/anki/models.py +++ b/anki/models.py @@ -147,7 +147,7 @@ class ModelManager(object): def rem(self, m): "Delete model, and all its cards/notes." - self.col.modSchema() + self.col.modSchema(check=True) current = self.current()['id'] == m['id'] # delete notes/cards self.col.remCards(self.col.db.list(""" @@ -241,7 +241,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) def setSortIdx(self, m, idx): assert idx >= 0 and idx < len(m['flds']) - self.col.modSchema() + self.col.modSchema(check=True) m['sortf'] = idx self.col.updateFieldCache(self.nids(m)) self.save(m) @@ -249,7 +249,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) def addField(self, m, field): # only mod schema if model isn't new if m['id']: - self.col.modSchema() + self.col.modSchema(check=True) m['flds'].append(field) self._updateFieldOrds(m) self.save(m) @@ -259,7 +259,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) self._transformFields(m, add) def remField(self, m, field): - self.col.modSchema() + self.col.modSchema(check=True) # save old sort field sortFldName = m['flds'][m['sortf']]['name'] idx = m['flds'].index(field) @@ -282,7 +282,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) self.renameField(m, field, None) def moveField(self, m, field, idx): - self.col.modSchema() + self.col.modSchema(check=True) oldidx = m['flds'].index(field) if oldidx == idx: return @@ -303,7 +303,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) self._transformFields(m, move) def renameField(self, m, field, newName): - self.col.modSchema() + self.col.modSchema(check=True) pat = r'{{(.*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}' def wrap(txt): def repl(match): @@ -347,7 +347,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord) def addTemplate(self, m, template): "Note: should col.genCards() afterwards." if m['id']: - self.col.modSchema() + self.col.modSchema(check=True) m['tmpls'].append(template) self._updateTemplOrds(m) self.save(m) @@ -370,7 +370,7 @@ having count() < 2 limit 1""" % ids2str(cids)): return False # ok to proceed; remove cards - self.col.modSchema() + self.col.modSchema(check=True) self.col.remCards(cids) # shift ordinals self.col.db.execute(""" @@ -414,7 +414,7 @@ select id from notes where mid = ?)""" % " ".join(map), # - newModel should be self if model is not changing def change(self, m, nids, newModel, fmap, cmap): - self.col.modSchema() + self.col.modSchema(check=True) assert newModel['id'] == m['id'] or (fmap and cmap) if fmap: self._changeNotes(nids, newModel, fmap) diff --git a/anki/storage.py b/anki/storage.py index d83fef1ca..e209c51ff 100644 --- a/anki/storage.py +++ b/anki/storage.py @@ -88,7 +88,7 @@ def _upgrade(col, ver): d['collapsed'] = False col.decks.save(d) if ver < 4: - col.modSchema() + col.modSchema(check=False) clozes = [] for m in col.models.all(): if not "{{cloze:" in m['tmpls'][0]['qfmt']: @@ -103,7 +103,7 @@ def _upgrade(col, ver): col.db.execute("update cards set odue = 0 where queue = 2") col.db.execute("update col set ver = 5") if ver < 6: - col.modSchema() + col.modSchema(check=False) import anki.models for m in col.models.all(): m['css'] = anki.models.defaultModel['css'] @@ -117,13 +117,13 @@ def _upgrade(col, ver): col.models.save(m) col.db.execute("update col set ver = 6") if ver < 7: - col.modSchema() + col.modSchema(check=False) col.db.execute( "update cards set odue = 0 where (type = 1 or queue = 2) " "and not odid") col.db.execute("update col set ver = 7") if ver < 8: - col.modSchema() + col.modSchema(check=False) col.db.execute( "update cards set due = due / 1000 where due > 4294967296") col.db.execute("update col set ver = 8") @@ -149,7 +149,7 @@ def _upgrade(col, ver): update cards set left = left + left*1000 where queue = 1""") col.db.execute("update col set ver = 10") if ver < 11: - col.modSchema() + col.modSchema(check=False) for d in col.decks.all(): if d['dyn']: order = d['order'] diff --git a/anki/sync.py b/anki/sync.py index f9464d87a..229ac4e5b 100644 --- a/anki/sync.py +++ b/anki/sync.py @@ -183,7 +183,7 @@ class Syncer(object): if ret['status'] != "ok": # roll back and force full sync self.col.rollback() - self.col.modSchema() + self.col.modSchema(False) self.col.save() return "sanityCheckFailed" # finalize diff --git a/aqt/main.py b/aqt/main.py index eff919904..246683dfe 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -69,7 +69,6 @@ class AnkiQt(QMainWindow): def setupUI(self): self.col = None - self.hideSchemaMsg = False self.setupAppMsg() self.setupKeys() self.setupThreads() @@ -265,7 +264,6 @@ To import into a password protected profile, please open the profile before atte ########################################################################## def loadCollection(self): - self.hideSchemaMsg = True cpath = self.pm.collectionPath() try: self.col = Collection(cpath, log=True) @@ -287,7 +285,6 @@ Debug info: return self.unloadProfile() raise - self.hideSchemaMsg = False self.progress.setupDB(self.col.db) self.maybeEnableUndo() self.moveToState("deckBrowser") @@ -903,12 +900,6 @@ and if the problem comes up again, please ask on the support site.""")) ########################################################################## def onSchemaMod(self, arg): - # if triggered in sync, make sure we don't use the gui - if not self.inMainThread(): - return True - # if from the full sync menu, ignore - if self.hideSchemaMsg: - return True return askUser(_("""\ The requested change will require a full upload of the database when \ you next synchronize your collection. If you have reviews or other changes \ diff --git a/aqt/preferences.py b/aqt/preferences.py index da9185cd4..37453d9b1 100644 --- a/aqt/preferences.py +++ b/aqt/preferences.py @@ -105,10 +105,8 @@ Not currently enabled; click the sync button in the main window to enable.""")) self.prof['autoSync'] = self.form.syncOnProgramOpen.isChecked() self.prof['syncMedia'] = self.form.syncMedia.isChecked() if self.form.fullSync.isChecked(): - self.mw.hideSchemaMsg = True - self.mw.col.modSchema() + self.mw.col.modSchema(check=False) self.mw.col.setMod() - self.mw.hideSchemaMsg = False # Backup ######################################################################