additional REST query: sync status?

Hi all,

I’m trying to write a tray icon that provides more visual cues for the sync status. I have a solution that loops over all devices and folders, checking the completion, needItems, etc, but, for 5 devices and 5 folders, this is 25 rest calls; it takes a few seconds, and my CPU spikes during the process.

I’m curious how difficult it would be to add an additional GET to the rest API to do this loop quickly in compiled code, then provide a dictionary of

{folder_id:
   {device_id1:
     {online:True,
      shared:True, 
      completion:100, 
      needItems:0, 
      needBytes:100,
      needDeletes:0}, 
    device_id2:{...},}}

Cheers, Jack

I’d check how the web UI does it. I can’t recall exactly how it works but suspect for some parts it uses the events API to not ask repeatedly when nothing changes, and for some parts it just subscribes to events that broadcast this information when/if it changes.

Yeah, that was going to be my next solution / set of questions for you, but it’s hard to tell at the outset which events are the best for triggering a full status check.

Okay after some fiddling I’ll try using LocalIndexUpdated to trigger a device-loop to check that folder, and I’ll use RemoteIndexUpdated to trigger a single folder+device check.

Let me know if there is a better way. :slight_smile:

Cheers, Jack

Listen to the FolderCompletion and FolderSummary events. To bootstrap your knowledge before receiving events, grab /rest/db/completion for the things you’re interested in, once at startup.