From f1c73999bee8903d0b71b200047f889dc07ef82c Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Sun, 14 Jan 2018 12:08:40 +0000 Subject: [PATCH] gui: Count deleted items for remote out of sync items display (fixes #4668) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4669 LGTM: calmh, AudriusButkevicius --- cmd/syncthing/gui.go | 9 ++++++--- cmd/syncthing/summaryservice.go | 13 ++++--------- gui/default/syncthing/core/syncthingController.js | 5 +++-- 3 files changed, 13 insertions(+), 14 deletions(-) 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);