-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete deletion of cards after clicking on sync manually #14
Comments
Hi Brian, sorry this happened — I'll investigate with the attachment you provided, but four quick points first:
Assuming (for now) that this was an issue of accidentally moving cards outside the synced folder before a sync, it's still a shame that that happened even if it's technically not a bug... maybe popping up a confirmation dialog before card deletions would make sense. I'll see if I can reproduce anything else with the sample vault you provided (thank you for that), and will update the issue. |
Thanks again for providing the vault and Anki package, very helpful. I've done some testing with the files provided, and at least from the state provided things are working as expected, because the ID of the notes in the Anki deck do not match the ID of the notes in Obsidian (except for one note, So, when the sync is requested, first deletes from Anki any notes it had previously created which do not have a local Obsidian note with a matching ID in its frontmatter. Likewise later in the sync, if a local note already has an ID in its frontmatter but no matching card is found in Anki, then the note is created in Anki and the frontmatter in the local Obsidian note is updated with the new ID. (Anki decides the values of the IDs, not Obsidian.) Before sync:
After sync:
After that, subsequent syncs also work as expected (with all cards unchanged) because the IDs in Obsidian and Anki match again. So, technically, exactly what we'd expect to happen from the state provided in your test files is happening, but then the more important question becomes.... what happened before when "creating some new cards, and moving some from there to here" to create the deviation between Anki and Obsidian in the first place? Were notes moved between vaults, possibly? Was auto-sync enabled at some point? Were cards temporarily moved out of the synced Are you using multiple Anki profiles? |
Also looking into whether this has something to do with unicode characters in the deck names, related to #13. |
Hi Brian, I investigated this further today and it seems like there is an edge case where the underlying Anki-Connect library that Yanki uses to communicate with Anki is reporting decks as being empty when they actually are not, which results in Yanki "cleaning up" decks it thinks are empty, deleting valid notes in the process. 😓 This seems to only occur only when there are special characters in the deck name, as you have in your So, mea culpa. I think I have a fix, and have included it in the latest 1.4.3 update. So please give that a try and let me know if you see this issue again. |
Hi, thank you very much for your attention, answering your questions: Were notes moved between vaults, possibly? And unfortunately it is not really possible to reproduce the error since the obsidian ids have been changed, but I will take the precaution of saving the yanki folder before synchronizing, so if the error occurs again (which I think you found the problem and it must be the characters) then I will send you a real reproduction of the problem. |
I'm going to assume that this is fixed since the related tests are passing on my end and I haven't heard any updates to the contrary in this thread. But please don't hesitate to reopen if you're still seeing this issue. |
Today it happened again, but luckily I made a backup before and I found out what happened that day I use Google Drive to sync my Obsidian vault folder, it must have been disconnected for a while and Obsidian simply disappeared with the vault, so I had to put it back, and there would be no problem if it weren't for a simple fact, every time you disconnect or disconnect the vault by itself, as was my case when using Google Drive, then you put it back in Obsidian it changes the "vault ID" and that's where the problem lies because it recreates everything again as if it were a new vault, but the biggest problem comes later, it changes all the IDs of the notes in Obsidian, leaving the progress unrecoverable, unless you have the backup before you clicked sync from Obsidian and Anki like I did, after recovering the backup from Obsidian and Anki I manually changed the ID of my vault in obsidian.json in AppData and I was able to recover my progress. What I learned so that this doesn't happen again is basically to check if the vault ID matches the vault ID in Anki, because if it doesn't, it's game over, I'll lose all my progress and I already have almost 500 study cards, it's going to be painful. What you could do would be to make it very clear in the plugin that disconnecting and connecting the vault (changes to the vault ID) will cause everything to be recreated again and will change the note IDs, making the progress unrecoverable. |
Thanks for the update. Your description tracks the expected behavior when the Vault ID changes — but I can't reproduce the part where the existing Anki notes created via a different vault are deleted from Anki after a Yanki sync. When I go through the process you describe of syncing from one Obsidian vault and then recreating the same note in another Obsidian vault, I just end up with duplicate notes in Anki with different values in the YankiNamespace fields and different Note IDs, which is consistent with the designed behavior. (The original bug in this thread where notes really were deleted should have been fixed.) Yanki is designed to never touch notes in Anki that don't match the the YankiNamespace used during a sync. Since your new vault will have a different YankiNamespace (derived from the Vault ID as you discovered) than the notes synced form the previous vault should not be deleted in Anki. If the notes with the previous YankiNamespace really were deleted in Anki, let me know and please provide the exact steps to reproduce. Regardless, I'm planning to make some changes to the namespace logic in a future version of Yanki to prevent this and also support some other synchronization cases:
|
After creating some new cards, and moving some from there to here and clicking to synchronize manually (I do this to avoid problems) it loaded and simply deleted all cards from my yanki in anki and changed all the IDs of my cards in obsidian, thus leaving my progress lost forever, even making a backup of my anki on my cell phone it does not recognize it and creates everything again because of the changed IDs in obsidian, thus making it not recognize the backup and create everything again.
Solution:
I don't know how you created this plugin, but a possible solution (at least for me it would be cool) would be to put the card's progress if it is for review or if it is new, anyway, leave this on Obsidian's side as the source of truth, but this would obviously create another problem: the person would study on their cell phone and when synchronizing with Obsidian they would lose their progress. So when synchronizing, get and download only all the card's progress to Obsidian and then upload all the changes along with the progress that already existed. Also create a button to do this by manually synchronizing the progress from Anki to Obsidian. This would at least avoid what happened to me of losing all the progress. I only have 80 cards, but imagine someone with 2k cards having to learn everything again because they lost their progress for some reason. It simply doesn't work. The best case scenario would be to have no error (but let's be honest, it's not hard for this shit to happen), but to have a way around it if it happens like what happened to me, simply delete EVERYTHING and change ALL IDs, thus making it irreversible. recovery, having a kind of backup ready in obsidian of the progress since the ensi cards are already the backup in obsidian the true source but the progress of the cards is missing, this is my suggestion, I know this would make it more complex but it would be ideal from my point of view.
Error reproduction:
I'm leaving a link below where I uploaded my Vault environment and also my Anki to simulate the error, just click on synchronize and the error should occur
https://drive.google.com/drive/folders/1oaGvJ84IQlM5gQ-3vQ03AJ0fwMxZaqow?usp=sharing
While we don't know what happened and the problem is not solved, if you know what could have been the cause so I can avoid doing so this problem doesn't happen again I would appreciate it.
The text was updated successfully, but these errors were encountered: