I am new to SyncThing and am testing the software out for a client use case. In this case I am using SyncThing to ‘transfer’ files between two servers for someone to access. However the data that is being transferred contains 100-300 files that in order to be opened all need to be present.
As a result I wrote a script to monitor the sync process via the REST API, and I am using the FolderCompletion event to monitor if the sync has fully completed. If the process is completed the script moves the files from the incoming sync folder to a location accessible by the end user. The idea is that the person trying to access the files will not be able to even see them until the sync is complete.
Everything was working as expected at first, the I noticed some odd behavior. Upon investigation I found the FolderCompletion event was returning only partial data.
This is the URI I am using:
It returns data, but only the globalBytes and globalItems are updating. The completion data parameter is always 100, and the needBytes, needDeletes, needItems are always 0, regardless of the sync status. The device and folder IDs are correct, and as I mentioned if I add or remove files the sync works and the globalBytes/globalItems are updated and correct.
This makes the script I wrote useless as I cannot actually know if the sync is complete since the completion parameter is always 100.
Both SyncThing version are 1.11.1 on Windows Servers
I have tried deleting the entire config and resetting up the sync folders and the problem persists. From what I can tell all other REST API calls I make return valid data.
Events api is an api that returns a stream of events.
Your query parameters are saying always return the first event only (since=0 limit=1).
The idea behind the api is that you call it with since=(last event id you’ve seen) in a loop.
Yes that is the intention since=0 (from start) limit=1 (only the last event).
However it does not matter, as I have already tried removing the parameters (since=0 limit=1). The stream of returned data is the same.
I have attached an image that I believe indicates the problem best. In the capture you can see the GUI interface is indicating a sync is in progress. Meanwhile the data returned from the API call only updates the globalBytes= and the globalItems= the other data returned (completion= needBytes= needItems= etc) are always the same, and thus incorrect/unreliable.
Folder completion events are for remote devices. Your screen shot shows one remote device, which appears 100% in sync.
You might be looking for the folder summary event.
Lol, well don’t I feel like the fool… I only didn’t clue into that it mentioned local/remote for content change but that it specifically mentions that the data presented back is for the remote device. I will update my scripts to use the FolderSummary event.
FolderCompletion event is emitted when the local or remote contents for a folder changes. It contains the completion percentage for a given remote device and is emitted once per currently connected remote device.
On the flip side, having spent N years working with syncthing, I feel even more of a fool assuming how since=0&limit=1 works.
I understood that this would return the first event always, but based on your screenshots it seems to return the last event.
I suspect (without having checked) it assumes 0 = not provided, but I definately did not expect that.
None of this is not confusing. Not least the naming of FolderCompletion vs FolderSummary.
(As for the since and limit, I think we start by selecting events by
since (i.e., all of them when since=0) and then apply
limit to the tail end of the list (selecting the
n latest events). since=0&limit=1 is documented as the way to get the latest event for resync-with-event-stream purposes.)
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.