mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
This commit is contained in:
parent
e1bf1e672e
commit
c025e76f30
@ -55,6 +55,7 @@ type folder struct {
|
|||||||
scanTimer *time.Timer
|
scanTimer *time.Timer
|
||||||
scanDelay chan time.Duration
|
scanDelay chan time.Duration
|
||||||
initialScanFinished chan struct{}
|
initialScanFinished chan struct{}
|
||||||
|
scanScheduled chan struct{}
|
||||||
versionCleanupInterval time.Duration
|
versionCleanupInterval time.Duration
|
||||||
versionCleanupTimer *time.Timer
|
versionCleanupTimer *time.Timer
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ func newFolder(model *model, fset *db.FileSet, ignores *ignore.Matcher, cfg conf
|
|||||||
scanTimer: time.NewTimer(0), // The first scan should be done immediately.
|
scanTimer: time.NewTimer(0), // The first scan should be done immediately.
|
||||||
scanDelay: make(chan time.Duration),
|
scanDelay: make(chan time.Duration),
|
||||||
initialScanFinished: make(chan struct{}),
|
initialScanFinished: make(chan struct{}),
|
||||||
|
scanScheduled: make(chan struct{}, 1),
|
||||||
versionCleanupInterval: time.Duration(cfg.Versioning.CleanupIntervalS) * time.Second,
|
versionCleanupInterval: time.Duration(cfg.Versioning.CleanupIntervalS) * time.Second,
|
||||||
versionCleanupTimer: time.NewTimer(time.Duration(cfg.Versioning.CleanupIntervalS) * time.Second),
|
versionCleanupTimer: time.NewTimer(time.Duration(cfg.Versioning.CleanupIntervalS) * time.Second),
|
||||||
|
|
||||||
@ -204,6 +206,10 @@ func (f *folder) Serve(ctx context.Context) error {
|
|||||||
l.Debugln(f, "Delaying scan")
|
l.Debugln(f, "Delaying scan")
|
||||||
f.scanTimer.Reset(next)
|
f.scanTimer.Reset(next)
|
||||||
|
|
||||||
|
case <-f.scanScheduled:
|
||||||
|
l.Debugln(f, "Scan was scheduled")
|
||||||
|
f.scanTimer.Reset(0)
|
||||||
|
|
||||||
case fsEvents := <-f.watchChan:
|
case fsEvents := <-f.watchChan:
|
||||||
l.Debugln(f, "Scan due to watcher")
|
l.Debugln(f, "Scan due to watcher")
|
||||||
err = f.scanSubdirs(fsEvents)
|
err = f.scanSubdirs(fsEvents)
|
||||||
@ -239,6 +245,14 @@ func (f *folder) DelayScan(next time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *folder) ScheduleScan() {
|
||||||
|
// 1-buffered chan
|
||||||
|
select {
|
||||||
|
case f.scanScheduled <- struct{}{}:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (f *folder) ignoresUpdated() {
|
func (f *folder) ignoresUpdated() {
|
||||||
if f.FSWatcherEnabled {
|
if f.FSWatcherEnabled {
|
||||||
f.scheduleWatchRestart()
|
f.scheduleWatchRestart()
|
||||||
|
@ -50,6 +50,7 @@ type service interface {
|
|||||||
Override()
|
Override()
|
||||||
Revert()
|
Revert()
|
||||||
DelayScan(d time.Duration)
|
DelayScan(d time.Duration)
|
||||||
|
ScheduleScan()
|
||||||
SchedulePull() // something relevant changed, we should try a pull
|
SchedulePull() // something relevant changed, we should try a pull
|
||||||
Jobs(page, perpage int) ([]string, []string, int) // In progress, Queued, skipped
|
Jobs(page, perpage int) ([]string, []string, int) // In progress, Queued, skipped
|
||||||
Scan(subs []string) error
|
Scan(subs []string) error
|
||||||
@ -2115,7 +2116,7 @@ func (m *model) SetIgnores(folder string, content []string) error {
|
|||||||
runner, ok := m.folderRunners[folder]
|
runner, ok := m.folderRunners[folder]
|
||||||
m.fmut.RUnlock()
|
m.fmut.RUnlock()
|
||||||
if ok {
|
if ok {
|
||||||
return runner.Scan(nil)
|
runner.ScheduleScan()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user