mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Anki is a smart spaced repetition flashcard program
![]() Syncing and shared decks have conflicting priorities: - For syncing, we need to ensure that the deck remains in a consistent state. In the past, Anki allowed deletions to be overriden by a more recently modified object, but this could lead to a broken deck in certain circumstances. For example, if a user deletes a fact (and its cards) on one side, but does something to bump a card's mod time on another side, then when syncing the card would be brought back to life without its fact. Short of complex code to check all the relations, we're limited to two options: forcing a full sync when things are deleted, or ensuring objects can't come back to life. - When facts are shared between people, we need a way to identify if two facts arose from the same source. We can't compare based on content, as the content may have changed partially or completely. And we can't use the timestamp ids because of the above restriction on bringing objects back to life. If we did that, people could download a shared deck, decide they don't want it, and delete it. When they later decide to add it again, it wouldn't be possible: either nothing would be imported because of the old graves, or the ids would have to be rewritten. If we do the latter, the facts are no longer associated with each other, and we lose the ability to update the deck. So we need to give facts two IDs: one used as the primary key and for syncing, and another 'global id' for importing/sharing. I used a 64 bit random number, because a) it's what Anki's used in the past, so by reusing the old IDs we don't break existing associations on upgrade, and b) it's a decent compromise between the possibility of conflicts and performance. Also re-added a flags column to the facts. The 'data' column is intended to store JSON in the future for extra features without changing the schema, but that's slow for simple state checks. Flags will be used as a bitmask. |
||
---|---|---|
anki | ||
tests | ||
tools | ||
.gitignore | ||
ChangeLog.old | ||
LICENSE |