mirror of
https://github.com/octoleo/syncthing.git
synced 2025-03-21 10:12:21 +00:00
This commit is contained in:
parent
9fef1552fc
commit
3446d50201
@ -8,7 +8,6 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -35,8 +34,6 @@ import (
|
|||||||
// scanLimiter limits the number of concurrent scans. A limit of zero means no limit.
|
// scanLimiter limits the number of concurrent scans. A limit of zero means no limit.
|
||||||
var scanLimiter = newByteSemaphore(0)
|
var scanLimiter = newByteSemaphore(0)
|
||||||
|
|
||||||
var errWatchNotStarted = errors.New("not started")
|
|
||||||
|
|
||||||
type folder struct {
|
type folder struct {
|
||||||
suture.Service
|
suture.Service
|
||||||
stateTracker
|
stateTracker
|
||||||
@ -564,19 +561,8 @@ func (f *folder) WatchError() error {
|
|||||||
func (f *folder) stopWatch() {
|
func (f *folder) stopWatch() {
|
||||||
f.watchMut.Lock()
|
f.watchMut.Lock()
|
||||||
f.watchCancel()
|
f.watchCancel()
|
||||||
prevErr := f.watchErr
|
|
||||||
f.watchErr = errWatchNotStarted
|
|
||||||
f.watchMut.Unlock()
|
f.watchMut.Unlock()
|
||||||
if prevErr != errWatchNotStarted {
|
f.setWatchError(nil)
|
||||||
data := map[string]interface{}{
|
|
||||||
"folder": f.ID,
|
|
||||||
"to": errWatchNotStarted.Error(),
|
|
||||||
}
|
|
||||||
if prevErr != nil {
|
|
||||||
data["from"] = prevErr.Error()
|
|
||||||
}
|
|
||||||
events.Default.Log(events.FolderWatchStateChanged, data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// scheduleWatchRestart makes sure watching is restarted from the main for loop
|
// scheduleWatchRestart makes sure watching is restarted from the main for loop
|
||||||
@ -641,7 +627,6 @@ func (f *folder) monitorWatch(ctx context.Context) {
|
|||||||
if _, ok := err.(*fs.ErrWatchEventOutsideRoot); ok {
|
if _, ok := err.(*fs.ErrWatchEventOutsideRoot); ok {
|
||||||
l.Warnln(err)
|
l.Warnln(err)
|
||||||
warnedOutside = true
|
warnedOutside = true
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aggrCancel()
|
aggrCancel()
|
||||||
@ -676,17 +661,18 @@ func (f *folder) setWatchError(err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if prevErr == errWatchNotStarted {
|
msg := fmt.Sprintf("Error while trying to start filesystem watcher for folder %s, trying again in 1min: %v", f.Description(), err)
|
||||||
l.Infof("Error while trying to start filesystem watcher for folder %s, trying again in 1min: %v", f.Description(), err)
|
if prevErr != err {
|
||||||
|
l.Infof(msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
l.Debugf("Repeat error while trying to start filesystem watcher for folder %s, trying again in 1min: %v", f.Description(), err)
|
l.Debugf(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanOnWatchErr schedules a full scan immediately if an error occurred while watching.
|
// scanOnWatchErr schedules a full scan immediately if an error occurred while watching.
|
||||||
func (f *folder) scanOnWatchErr() {
|
func (f *folder) scanOnWatchErr() {
|
||||||
f.watchMut.Lock()
|
f.watchMut.Lock()
|
||||||
if f.watchErr != nil && f.watchErr != errWatchNotStarted {
|
if f.watchErr != nil {
|
||||||
f.Delay(0)
|
f.Delay(0)
|
||||||
}
|
}
|
||||||
f.watchMut.Unlock()
|
f.watchMut.Unlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user