Skip to main content

spawn_auto_sync

Function spawn_auto_sync 

Source
pub fn spawn_auto_sync(
    db_path: PathBuf,
    on_state: impl Fn(bool) + Send + 'static,
) -> Option<JoinHandle<()>>
Expand description

Keep the library in step with the server, without being asked.

One sync shortly after startup, then every auto_sync_interval_mins. Always incremental: it asks the server what changed rather than walking the whole library, which is what makes it cheap enough to run unattended. A full sync stays a deliberate action.

The startup run is delayed a few seconds so it is not competing with the first frame and the first track for the disk.

on_state reports whether a sync is running, so a UI can say so rather than appearing to do nothing.