mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
when ensuring model unique, check id not obj
this should fix an issue where we were attaching a suffix to non-duplicate names on sync
This commit is contained in:
parent
f23392b6a3
commit
f1837e7e0a
2 changed files with 5 additions and 3 deletions
|
@ -167,8 +167,10 @@ select id from cards where nid in (select id from notes where mid = ?)""",
|
|||
self.save(m)
|
||||
|
||||
def ensureNameUnique(self, m):
|
||||
if m['name'] in self.allNames(m):
|
||||
m['name'] += "-" + checksum(str(time.time()))[:5]
|
||||
for mcur in self.all():
|
||||
if (mcur['name'] == m['name'] and
|
||||
mcur['id'] != m['id']):
|
||||
m['name'] += "-" + checksum(str(time.time()))[:5]
|
||||
|
||||
def update(self, m):
|
||||
"Add or update an existing model. Used for syncing and merging."
|
||||
|
|
|
@ -100,7 +100,7 @@ def test_models():
|
|||
time.sleep(1)
|
||||
deck1.models.save(cm)
|
||||
deck1.save()
|
||||
assert deck2.models.get(cm['id'])['name'] == "Basic"
|
||||
assert deck2.models.get(cm['id'])['name'].startswith("Basic")
|
||||
assert client.sync() == "success"
|
||||
assert deck2.models.get(cm['id'])['name'] == "new"
|
||||
# deleting triggers a full sync
|
||||
|
|
Loading…
Reference in a new issue