-
-
Notifications
You must be signed in to change notification settings - Fork 43
Workarounds — Duplicate note model uuids
Due to a bug in the interaction between CrowdAnki and Anki, when a note model (aka note type) with an already assigned crowdanki_uuid
, was duplicated, its clone inherited its crowdanki_uuid
. This, in turn, meant that when a deck containing both the original note model and its clone was exported, only one of the note models was included in the export. This lead to many problems (e.g. #121, #123, #134).
This bug was present up to and including v0.9.
The bug is mostly fixed in master
(see #136) and will be fixed in v0.9.1.
Using the following script for the Anki debug console you can check whether you're affected (whether any of your crowdanki_uuid
s are duplicated).
Debug console script
repeated = {}
for model in filter(lambda model: 'crowdanki_uuid' in model,
self.col.models.all()):
cu = model["crowdanki_uuid"]
if cu in repeated:
repeated[cu] = True
else:
repeated[cu] = False
if any(repeated.values()):
print("WARNING! There are repeated Note Model uuids!")
else:
print("There are no repeated Note Model uuids! Everything is OK!")
Using the following script for the Anki debug console you can disambiguate the currently duplicated crowdanki_uuid
s. Note that unless you're using the latest version of CrowdAnki (v0.9.1 or later), this won't prevent the crowdanki_uuid
from being duplicated when you create a new note model via cloning.
Debug console script
from uuid import uuid1
uuids = []
for model in filter(lambda model: 'crowdanki_uuid' in model,
sorted(self.col.models.all(), key=lambda m: m["id"])):
# we're sorting in the hope that note models with higher ids
# (which mostly corresponds to creation date) were created later,
# so we change the uuid of the copies, not the original
cu = model["crowdanki_uuid"]
if cu in uuids:
print("Replacing UUID for note model " + model["name"] + "!")
model["crowdanki_uuid"] = str(uuid1())
self.col.models.save(model)
else:
uuids.append(cu)