Skip to main content

Module sync

Module sync 

Source
Expand description

Picking up changes other apps make to an open library: a sync tool (Dropbox, iCloud, Syncthing), Eagle on another machine, or the falcon CLI.

Eagle polls metadata.json and mtime.json every 4 seconds (fs.watchFile). When metadata.json changed and its modificationTime is later than the one in memory, it takes the new folder tree. When mtime.json changed, it compares it with the stamps it knows: ids it hasn’t seen are new items and larger stamps are edited ones, whose metadata.json it reads again; when the all count no longer matches the items it holds, it lists images/ to find items that were deleted (and new folders missing from the index).

Here the polling and file reading happen on the app’s thread of choice (Probe, read_metadata, read_mtime); applying is quick and done with the library locked (Library::take_external_metadata, Library::sync_items). Applying never writes: the changes are already on disk. falcon’s own writes come back through the same path and change nothing, since their stamps are the ones in memory.

Structs§

ItemSync
What Library::sync_items changed in memory.
Probe
What a poll of the library folder found.

Constants§

POLL
How often Eagle polls the two files.

Functions§

read_metadata
Reads and parses metadata.json (an unfinished or damaged file is an error; poll again later).
read_mtime
Reads and parses mtime.json.