Force syncing of media after import #214
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Otherwise, if in the source CrowdAnki decks a file has only been edited, this won't be synced to other devices.
By default, Anki only checks whether it should more expensively check for changes to individual media files if the mtime of the entire media directory has changed.
(According to the docs:
https://docs.ankiweb.net/syncing.html#media
However, the mechanism by which it checks for this is via the directory is (currently!) via the mtime of the dir:
https://github.com/ankitects/anki/blob/b7cb0c0d0081202586fd2d88541db962819736b3/rslib/src/sync/media/database/client/changetracker.rs#L94
)
Note that this means that every time CrowdAnki imports a deck, with media, Anki will have to perform the more expensive check.
The cost of this "second" check was deemed sufficiently high that the current behaviour (of two checks) was (re-)introduced here:
ankitects/anki@35cbde6
However, given that importing CrowdAnki decks is not a frequent occurrence (probably less frequent than adding new media files oneself — which also triggers the "second" check), this is a worthwhile change.
For background see here:
anki-geo/ultimate-geography#638 (comment)