perf: Speed up media_names_for_ankihub_deck - #1380
Conversation
|
The
None of which the code says anywhere, which is what made that function look safe to swap out — so it's worth adding a comment on it recording why it reads the collection rather than The And for what it's worth, keeping the collection scan costs almost nothing: on that same collection the existing |
|
Thanks. I reverted the change and added a comment. Originally I made the change because I suspected a deadlock issue caused by non-serialized collection access, but I couldn't confirm that. |
Related issues
This came up after my investigation of this community report: https://community.ankihub.net/t/i-accidently-deleted-the-anking-media-folder-from-my-laptop/605714
Proposed changes
This implements some small performance improvements for media sync:
Replace_media_referenced_by_notes(which extracts media references from the live Anki collection) with a call toankihub_db.media_names_for_ankihub_deck().media_names_for_ankihub_deckto avoid holding all note rows in memory.How to reproduce
Media sync should work normally. This is mostly a performance improvement (but see note below).
Further comments
Locally deleted notes now count and their media gets downloaded. I think this is acceptable considering that the sync process restores deleted notes if they get updates.