gui, lib/scanner: Improve scan progress indication (ref #8331) (#9308)

This commit is contained in:
Simon Frei
2023-12-31 23:01:16 +01:00
committed by GitHub
parent 1ce2af1238
commit 2f3eacdb6c
2 changed files with 34 additions and 13 deletions
@@ -1039,18 +1039,29 @@ angular.module('syncthing.core')
// Do the same thing in case we only have zero byte files to sync.
return 95;
}
var pct = 100 * $scope.model[folder].inSyncBytes / $scope.model[folder].globalBytes;
return Math.floor(pct);
return progressIntegerPercentage($scope.model[folder].inSyncBytes, $scope.model[folder].globalBytes);
};
$scope.scanPercentage = function (folder) {
if (!$scope.scanProgress[folder]) {
return undefined;
}
var pct = 100 * $scope.scanProgress[folder].current / $scope.scanProgress[folder].total;
return Math.floor(pct);
return progressIntegerPercentage($scope.scanProgress[folder].current, $scope.scanProgress[folder].total);
};
function progressIntegerPercentage(current, total) {
// Even after whatever is being tracked (e.g. hashed or synced
// bytes) is completed, there's likely some more work to be done to
// fully finish the process (db updates, ...). Users apparently
// don't like seeing 100%, so give them 99% to indicate "about to be
// finished".
if (current === total) {
return 99;
}
var pct = 100 * current / total;
return Math.floor(pct);
}
$scope.scanRate = function (folder) {
if (!$scope.scanProgress[folder]) {
return 0;