lib/scanner: Refactor scanner.Walk API
The old usage pattern was to create a Walker with a bunch of attributes, then call Walk() on it and nothing else. This extracts the attributes into a Config struct and exposes a Walk(cfg Config) method instead, as there was no reason to expose the state-holding walker type. Also creates a few no-op implementations of the necessary interfaces so that we can skip nil checks and simiplify things here and there. Definitely look at this diff without whitespace. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3060
This commit is contained in:
committed by
Audrius Butkevicius
parent
d77d8ff803
commit
21e116aa45
@@ -1401,7 +1401,9 @@ func (m *Model) internalScanFolderSubdirs(folder string, subs []string) error {
|
||||
cancel := make(chan struct{})
|
||||
defer close(cancel)
|
||||
|
||||
w := &scanner.Walker{
|
||||
runner.setState(FolderScanning)
|
||||
|
||||
fchan, err := scanner.Walk(scanner.Config{
|
||||
Folder: folderCfg.ID,
|
||||
Dir: folderCfg.Path(),
|
||||
Subs: subs,
|
||||
@@ -1417,11 +1419,8 @@ func (m *Model) internalScanFolderSubdirs(folder string, subs []string) error {
|
||||
ShortID: m.shortID,
|
||||
ProgressTickIntervalS: folderCfg.ScanProgressIntervalS,
|
||||
Cancel: cancel,
|
||||
}
|
||||
})
|
||||
|
||||
runner.setState(FolderScanning)
|
||||
|
||||
fchan, err := w.Walk()
|
||||
if err != nil {
|
||||
// The error we get here is likely an OS level error, which might not be
|
||||
// as readable as our health check errors. Check if we can get a health
|
||||
|
||||
Reference in New Issue
Block a user