Hi,
By using the syncthing REST API I can get information about both global and local state for a particular file (see http://docs.syncthing.net/rest/db-file-get.html and below) . But how can I know if that file is in sync? By beeing in sync, I mean that the local file is the latest and greatest, not necessarily that the file has been synced to other devices. I have some alternative I am thinking of.
-
The localVersion seems irrelevant and seems to be just that, local.
-
The version looks promising. But what if the local version is recently changed, and thoose changes has not been propagated to the global yet? From the local device perspective, the file is the latest version and thus in sync, even if the changes has not been propagated in to global yet, and local:version differs from global:version. Is the “version” an hash? If so, what is the integer part after the colon?
-
Do I have to compare modified time to be sure? (Which can be a bit messy if the devices are in different time zones)
-
Are the flags maybe containing one flag that can tell if the file is in sync? It do look like file permissions though.
Finally I also wonder if this information are to be accurate first after next scan, so that maybe it is an idea to do a scan (/rest/db/scan
) on that particular file only, before calling this api?
From the documentation:
{ "availability": [
"I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" ], "global": {
"flags": "0644",
"localVersion": 3,
"modified": "2015-04-20T22:20:45+09:00",
"name": "util.go",
"numBlocks": 1,
"size": 9642,
"version": [
"5407294127585413568:1"
] }, "local": {
"flags": "0644",
"localVersion": 4,
"modified": "2015-04-20T22:20:45+09:00",
"name": "util.go",
"numBlocks": 1,
"size": 9642,
"version": [
"5407294127585413568:1"
] } }