mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 07:12:27 +00:00
parent
1ce2af1238
commit
2f3eacdb6c
@ -1039,18 +1039,29 @@ angular.module('syncthing.core')
|
|||||||
// Do the same thing in case we only have zero byte files to sync.
|
// Do the same thing in case we only have zero byte files to sync.
|
||||||
return 95;
|
return 95;
|
||||||
}
|
}
|
||||||
var pct = 100 * $scope.model[folder].inSyncBytes / $scope.model[folder].globalBytes;
|
return progressIntegerPercentage($scope.model[folder].inSyncBytes, $scope.model[folder].globalBytes);
|
||||||
return Math.floor(pct);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.scanPercentage = function (folder) {
|
$scope.scanPercentage = function (folder) {
|
||||||
if (!$scope.scanProgress[folder]) {
|
if (!$scope.scanProgress[folder]) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
var pct = 100 * $scope.scanProgress[folder].current / $scope.scanProgress[folder].total;
|
return progressIntegerPercentage($scope.scanProgress[folder].current, $scope.scanProgress[folder].total);
|
||||||
return Math.floor(pct);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
$scope.scanRate = function (folder) {
|
||||||
if (!$scope.scanProgress[folder]) {
|
if (!$scope.scanProgress[folder]) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -160,6 +160,11 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
total += file.Size
|
total += file.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(filesToHash) == 0 {
|
||||||
|
close(finishedChan)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
realToHashChan := make(chan protocol.FileInfo)
|
realToHashChan := make(chan protocol.FileInfo)
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
progress := newByteCounter()
|
progress := newByteCounter()
|
||||||
@ -171,13 +176,7 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
go func() {
|
go func() {
|
||||||
defer progress.Close()
|
defer progress.Close()
|
||||||
|
|
||||||
for {
|
emitProgressEvent := func() {
|
||||||
select {
|
|
||||||
case <-done:
|
|
||||||
l.Debugln(w, "Walk progress done", w.Folder, w.Subs, w.Matcher)
|
|
||||||
ticker.Stop()
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
current := progress.Total()
|
current := progress.Total()
|
||||||
rate := progress.Rate()
|
rate := progress.Rate()
|
||||||
l.Debugf("%v: Walk %s %s current progress %d/%d at %.01f MiB/s (%d%%)", w, w.Folder, w.Subs, current, total, rate/1024/1024, current*100/total)
|
l.Debugf("%v: Walk %s %s current progress %d/%d at %.01f MiB/s (%d%%)", w, w.Folder, w.Subs, current, total, rate/1024/1024, current*100/total)
|
||||||
@ -187,6 +186,17 @@ func (w *walker) walk(ctx context.Context) chan ScanResult {
|
|||||||
"total": total,
|
"total": total,
|
||||||
"rate": rate, // bytes per second
|
"rate": rate, // bytes per second
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
emitProgressEvent()
|
||||||
|
l.Debugln(w, "Walk progress done", w.Folder, w.Subs, w.Matcher)
|
||||||
|
ticker.Stop()
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
emitProgressEvent()
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user