Use _modSchemaIfRequired in all cases.

Same logic than in last commit. Actually, there is no change of model
which need a full sync until the model is uploaded. After all, even if
a change in model imply that some card will change, those cards and
notes have not been uploaded either
This commit is contained in:
Arthur Milchior 2019-10-23 04:48:14 +02:00
parent b78480fe52
commit 9863b6f9ff

View File

@ -155,7 +155,7 @@ class ModelManager:
def rem(self, m):
"Delete model, and all its cards/notes."
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
current = self.current()['id'] == m['id']
# delete notes/cards
self.col.remCards(self.col.db.list("""
@ -249,7 +249,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
def setSortIdx(self, m, idx):
assert 0 <= idx < len(m['flds'])
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
m['sortf'] = idx
self.col.updateFieldCache(self.nids(m))
self.save(m)
@ -265,7 +265,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
self._transformFields(m, add)
def remField(self, m, field):
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
# save old sort field
sortFldName = m['flds'][m['sortf']]['name']
idx = m['flds'].index(field)
@ -288,7 +288,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
self.renameField(m, field, None)
def moveField(self, m, field, idx):
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
oldidx = m['flds'].index(field)
if oldidx == idx:
return
@ -309,7 +309,7 @@ and notes.mid = ? and cards.ord = ?""", m['id'], ord)
self._transformFields(m, move)
def renameField(self, m, field, newName):
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
pat = r'{{([^{}]*)([:#^/]|[^:#/^}][^:}]*?:|)%s}}'
def wrap(txt):
def repl(match):
@ -375,7 +375,7 @@ having count() < 2
limit 1""" % ids2str(cids)):
return False
# ok to proceed; remove cards
self.col.modSchema(check=True)
self._modSchemaIfRequired(m)
self.col.remCards(cids)
# shift ordinals
self.col.db.execute("""
@ -419,7 +419,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(check=True)
self._modSchemaIfRequired(m)
assert newModel['id'] == m['id'] or (fmap and cmap)
if fmap:
self._changeNotes(nids, newModel, fmap)