I have a shell script using the events API and am struggling to check whether sync is “finished” more prior to system shutdown and also on system startup. Technically a sync is never finished because it’s syncing continuously, but for the purposes above, the best definition probably means that “within say a minute of timeout, at least a file was synced (indicating at least any remaining files should be synced at that moment as well) and then no more files are synced”.
To be clear, LocalIndexUpdated
/RemoteIndexUpdated
is emitted when a file is synced (i.e. changed)? Brief test shows that this seems to be working as expected except this: a LocalIndexUpdated
emitted for 2 particular directories (one a parent of the other) that were never touched (including any of its files) and I’m not sure why. To confirm, the GUI lists “recent changes” and it labeled these directories as “modified dirs” while the rest of the recently changed files listed do not involve this path. Its modified time according to ls
is older, i.e. it does not reflect what is reported by Syncthing.
Any ideas? Is simply checking for LocalIndexUpdated
/RemoteIndexUpdated
within a timeout period the best way to check for syncing completion? I was also considering StateChanged
but its .data.from
and .data.to=idle
but .data.from
seems to have more states besides what’s mentioned in the docs, e.g. sync-waiting
, sync-waiting
, and sync-preparing
so doesn’t be so straightforward.