diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 2784aa11b..232b33c5c 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -665,14 +665,17 @@ func (s *apiService) getDBCompletion(w http.ResponseWriter, r *http.Request) { return } - comp := s.model.Completion(device, folder) - sendJSON(w, map[string]interface{}{ + sendJSON(w, jsonCompletion(s.model.Completion(device, folder))) +} + +func jsonCompletion(comp model.FolderCompletion) map[string]interface{} { + return map[string]interface{}{ "completion": comp.CompletionPct, "needBytes": comp.NeedBytes, "needItems": comp.NeedItems, "globalBytes": comp.GlobalBytes, "needDeletes": comp.NeedDeletes, - }) + } } func (s *apiService) getDBStatus(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/syncthing/summaryservice.go b/cmd/syncthing/summaryservice.go index c437d8efd..0a8417205 100644 --- a/cmd/syncthing/summaryservice.go +++ b/cmd/syncthing/summaryservice.go @@ -205,15 +205,10 @@ func (c *folderSummaryService) sendSummary(folder string) { // Get completion percentage of this folder for the // remote device. - comp := c.model.Completion(devCfg.DeviceID, folder) - events.Default.Log(events.FolderCompletion, map[string]interface{}{ - "folder": folder, - "device": devCfg.DeviceID.String(), - "completion": comp.CompletionPct, - "needBytes": comp.NeedBytes, - "needItems": comp.NeedItems, - "globalBytes": comp.GlobalBytes, - }) + comp := jsonCompletion(c.model.Completion(devCfg.DeviceID, folder)) + comp["folder"] = folder + comp["device"] = devCfg.DeviceID.String() + events.Default.Log(events.FolderCompletion, comp) } } diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index f441344b1..47f7e54e2 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -495,7 +495,7 @@ angular.module('syncthing.core') } else { $scope.completion[device]._total = Math.floor(100 * (1 - needed / total)); $scope.completion[device]._needBytes = needed - $scope.completion[device]._needItems = items; + $scope.completion[device]._needItems = items + deletes; } if (needed == 0 && deletes > 0) { @@ -2054,7 +2054,8 @@ angular.module('syncthing.core') resetRemoteNeed(); $scope.remoteNeedDevice = device; $scope.deviceFolders(device).forEach(function(folder) { - if ($scope.completion[device.deviceID][folder] !== undefined && $scope.completion[device.deviceID][folder].needItems === 0) { + var comp = $scope.completion[device.deviceID][folder]; + if (comp !== undefined && comp.needItems + comp.needDeletes === 0) { return; } $scope.remoteNeedFolders.push(folder);