Closed jorgebg closed 4 years ago
Hello! I use genanki to manage my deck, and asked similar questions before, but about the Notes guid
.
I did a bit of testing with mock decks on a trial Anki install. Quoting this comment:
As far as I can tell, the
guid
is the only value that is used to determine if imported cards are news or updates. Note ID and Card ID are internal to each Anki installation:
they have to remain unique in each installation
when importing, Anki will ensure there are no duplicates by changing the imported ID when necessary
the internal IDs of the database inside the
.pkg
file, have to be consistent from cards to notes (this is managed on creation through genanki scripts)
I also remember that whenever Anki sees a new model_id
, it will create a new model in it's database. If the name collides, then Anki will append a small random uuid to the name of the newly imported model.
Same goes for the deck_id
. When Anki imports a deck with an ID that was never seen before, it will create a blank new deck and import cards in it (even if cards guid
are the same as in another deck).
I hope this is a start to answers. We could do more tests to determine exactly what is important to Anki.
Thank you so much for the info, @remiberthoz!
@remiberthoz is right here. The reason you can't randomly generate a deck ID, or use some other solution like a single global deck ID for all genanki users or choose deck ID by hashing deck properties, is that if the deck ID changes it will result in a new deck being created when you import the generated .apkg
file a second time, rather than updating the existing deck. The same is true for models. There's no simple, reliable way to abstract this away from the user.
Thanks for the clarification, @kerrickstaley
First of all, thank you for this awesome tool.
I have a few questions about the model id and deck id behavior. According the README, the model id must be randomly generated and then hardcoded into the source code:
Same for the deck id:
After reading this, I have the following questions:
How do the model and deck ids work in Anki? Can the model id be unique per deck? What if my deck id collides with another deck already imported in my Anki profile?
Also, why does the id need to be hardcoded? Can the change the deck id change on future versions? What would happen in that case?