How does anki desktop sync to anki web?

I’m a bit curious as to how this actually works.

Does anki take everything in the collections.media directory and somehow just throw it online?

If someone could explain this, it would help me a lot.

1 Like

The relevant function in the anki desktop codebase is at rslib/src/media/sync.rs:determine_required_changes, it calculates a diff of your local files with the server.

From what I can gather, a Sha1sum hash of each of your remote files on the server is fetched from the server (by the function fetch_record_batch() in the same file) and passed to determine_required_changes() which then checks your local files to see which ones differ (by comparing their hashes), and decide what action is needed to get the files in sync with the server.

So to summarize, it’s not taking everything in your media directory and re-uploading it each time. Instead, it’s essentially reading a lightweight manifest describing the files on the server, and using that to determine which of your local files differ (or don’t yet exist on the server).

1 Like