Stvad / CrowdAnki

Plugin for Anki SRS designed to facilitate cooperation on creation of notes and decks.
MIT License
520 stars 44 forks source link

Can't delete cards via CrowdAnki #211

Open LorenzHorvath opened 1 month ago

LorenzHorvath commented 1 month ago

Hey!

I've recently stumbled across an issue whilst collaborating on a deck with a colleague:

  1. I deleted some cards
  2. I pushed the changes to the repo
  3. He pulled and imported the deck
  4. The cards which I deleted are still present, as they have been present before locally and CrowdAnki seems to encounter them as 'new' cards
  5. He then pushed some unrelated changes, but with them he also pushed the cards I previously deleted on the repo again, inadvertently undoing my changes

Is there anything to be done about this? I couldn't find any config option regarding this issue. 😅

aplaice commented 1 month ago

Thanks for reporting! This is unfortunately a known problem with no automatic solution, as of now. In "Ultimate Geography" we work around this by creating a "dummy" deck with the deleted cards, so that the user can import the "dummy" deck (hence moving the cards into it) and then delete it, but this is not really a viable solution for collaboration.


Musings on technical approach

I'm not quite sure what would be the best solution — one option might be to have an extra "deleted.yaml" file in each CrowdAnki repo (or maybe just a field in the JSON??), with the guids/uuids of deleted notes, which would be automatically updated when deleting notes, and on the import side the user would be asked whether they want to delete the remotely deleted notes (and depending on the user's choice either delete them or tag them as something like "crowdanki_deleted", and in both cases ignore them on re-export). The main disadvantage is that the list of deleted notes could never really be pruned. (There might be some others that I can't think of...) (Undeletion would be handled by removing the uuid from the "deleted" list.)

A more elegant (but in practice also far more complicated...) solution would be to rely on the git repo history to track whether (when importing an existing deck) the absence of a note (i.e. that it is present in the local collection but not in the imported deck) is due to the note having been remotely removed or never present (just like Git normally knows when files/lines are deleted when pulling). The disadvantage would be that this would rely on the diffs being sufficiently clean that git can reliably distinguish deleted notes, and that it'd rely on the deck being imported from a git repo and not just from a file/directory.

wyohm commented 1 month ago

One idea on the deck side would be to have a deck version number tag, e.g. "v1". When preparing to push again, add "v2" and remove "v1" for all cards. When others pull, any cards which have "v1" (or don't have "v2") can be deleted.

LorenzHorvath commented 1 month ago

Thanks for the reply!

A "deleted.yaml" also was the first thing that came to my mind, would surely be a nice addition to the addon!

Our makeshift solution is quite similar to @wyohm's, we just add a DELETE tag to each card we want to "delete" and make sure to suspend all cards tagged DELETE after each pull. Not a nice solution of course, but one that works and doesn't rely on the other party making good on their promise of deleting cards marked for deletion in some way or another before committing.