gui, lib/model: Add new state FolderPreparingSync (fixes #6027) (#6028)

This commit is contained in:
Simon Frei 2019-10-16 09:08:54 +02:00 committed by Jakob Borg
parent 031684116b
commit 7b33294955
4 changed files with 39 additions and 23 deletions

View File

@ -323,6 +323,10 @@
<span class="visible-xs" aria-label="{{'Scanning' | translate}}"><i class="fas fa-fw fa-search"></i></span>
</span>
<span ng-switch-when="idle"><span class="hidden-xs" translate>Up to Date</span><span class="visible-xs" aria-label="{{'Up to Date' | translate}}"><i class="fas fa-fw fa-check"></i></span></span>
<span ng-switch-when="sync-preparing">
<span class="hidden-xs" translate>Preparing to Sync</span>
<span class="visible-xs" aria-label="{{'Preparing to Sync' | translate}}"><i class="fas fa-fw fa-hourglass-half"></i></span>
</span>
<span ng-switch-when="syncing">
<span class="hidden-xs" translate>Syncing</span>
<span>({{syncPercentage(folder.id) | percent}}, {{model[folder.id].needBytes | binary}}B)</span>

View File

@ -803,7 +803,7 @@ angular.module('syncthing.core')
if (status == 'paused') {
return 'default';
}
if (status === 'syncing' || status === 'scanning') {
if (status === 'syncing' || status === 'sync-preparing' || status === 'scanning') {
return 'primary';
}
if (status === 'unknown') {
@ -968,6 +968,7 @@ angular.module('syncthing.core')
for (var i = 0; i < folderListCache.length; i++) {
var status = $scope.folderStatus(folderListCache[i]);
switch (status) {
case 'sync-preparing':
case 'syncing':
syncCount++;
break;

View File

@ -176,7 +176,6 @@ func (f *sendReceiveFolder) pull() bool {
l.Debugf("%v pulling", f)
f.setState(FolderSyncing)
f.clearPullErrors()
scanChan := make(chan string)
@ -194,6 +193,10 @@ func (f *sendReceiveFolder) pull() bool {
default:
}
// Needs to be set on every loop, as the puller might have set
// it to FolderSyncing during the last iteration.
f.setState(FolderSyncPreparing)
changed := f.pullerIteration(scanChan)
l.Debugln(f, "changed", changed, "on try", tries+1)
@ -1396,6 +1399,8 @@ func (f *sendReceiveFolder) pullerRoutine(in <-chan pullBlockState, out chan<- *
continue
}
f.setState(FolderSyncing) // Does nothing if already FolderSyncing
// The requestLimiter limits how many pending block requests we have
// ongoing at any given time, based on the size of the blocks
// themselves.

View File

@ -19,6 +19,7 @@ const (
FolderIdle folderState = iota
FolderScanning
FolderScanWaiting
FolderSyncPreparing
FolderSyncing
FolderError
)
@ -31,6 +32,8 @@ func (s folderState) String() string {
return "scanning"
case FolderScanWaiting:
return "scan-waiting"
case FolderSyncPreparing:
return "sync-preparing"
case FolderSyncing:
return "syncing"
case FolderError:
@ -65,7 +68,12 @@ func (s *stateTracker) setState(newState folderState) {
}
s.mut.Lock()
if newState != s.current {
defer s.mut.Unlock()
if newState == s.current {
return
}
/* This should hold later...
if s.current != FolderIdle && (newState == FolderScanning || newState == FolderSyncing) {
panic("illegal state transition " + s.current.String() + " -> " + newState.String())
@ -87,8 +95,6 @@ func (s *stateTracker) setState(newState folderState) {
s.evLogger.Log(events.StateChanged, eventData)
}
s.mut.Unlock()
}
// getState returns the current state, the time when it last changed, and the
// current error or nil.