lib/model: Refactor encapsulation of the folder scanning
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3017
This commit is contained in:
committed by
Jakob Borg
parent
4bf3e7485b
commit
af0bc95de5
@@ -107,18 +107,10 @@ type rwFolder struct {
|
||||
func newRWFolder(model *Model, cfg config.FolderConfiguration, ver versioner.Versioner) service {
|
||||
f := &rwFolder{
|
||||
folder: folder{
|
||||
stateTracker: stateTracker{
|
||||
folderID: cfg.ID,
|
||||
mut: sync.NewMutex(),
|
||||
},
|
||||
scan: folderscan{
|
||||
interval: time.Duration(cfg.RescanIntervalS) * time.Second,
|
||||
timer: time.NewTimer(time.Millisecond), // The first scan should be done immediately.
|
||||
now: make(chan rescanRequest),
|
||||
delay: make(chan time.Duration),
|
||||
},
|
||||
stop: make(chan struct{}),
|
||||
model: model,
|
||||
stateTracker: newStateTracker(cfg.ID),
|
||||
scan: newFolderScanner(cfg),
|
||||
stop: make(chan struct{}),
|
||||
model: model,
|
||||
},
|
||||
|
||||
virtualMtimeRepo: db.NewVirtualMtimeRepo(model.db, cfg.ID),
|
||||
@@ -297,7 +289,7 @@ func (f *rwFolder) Serve() {
|
||||
// same time.
|
||||
case <-f.scan.timer.C:
|
||||
err := f.scanSubdirsIfHealthy(nil)
|
||||
f.scan.reschedule()
|
||||
f.scan.Reschedule()
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user