The add-on uses a local SQLite database file named “ankihub.db” to cache data and avoid making a lot of network requests. There are cases where some data in the file gets messed up, causing persistent errors on every sync (e.g. suggestions with mismatching fields). I sometimes suggested to users deleting the file to work around some errors, but this can cause other problems like the add-on no longer being able to detect whether a note can be suggested to a given deck, unless the deck is reinstalled. An option to rebuild the database or parts of it would be safer to suggest to users.
@jakub.f , what do you think? I think we should always avoid
- asking users to run code in the console
- asking users to manually modify files in the add-on directory
I understand if this is sometimes necessary, but we should definitely avoid this as much as possible as I fear it will make a negative impression on some users.
Jakub and I previously talked about making the AnkiHub database disposable/reproducible. However, I think it would be best if the add-on handled recreating the DB automatically when necessary. That said, perhaps we can have a menu item that will run some functions to get things back into a “clean” state
Adding an option to check and rebuild the database seems like a good idea. We should strive towards making it unnecessary by preventing bad data in the database and fixing it automatically if possible. However it takes time for us to become aware of problems, find their causes and implement solutions. So it would be good if users could just use this troubleshooting option to fix the problem immediately. On the other hand we definitely don’t want users to use this option frequently.
I would imagine the option would just clear all data from the add-on’s db and re-download decks, note types and media metadata for the installed decks. If the process gets interrupted, it should probably resume when the add-on is started again.
@abdo Do you know about more problems with the data in the database besides the mismatched fields?
I suggested deleting the DB to fix this issue for example: Everytime I sync or close anki, i get this error message about ankihub
The option would be useful for unforeseeable issues too.