2016-04-26 14:01:46 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
2017-02-09 06:52:18 +00:00
|
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-04-26 14:01:46 +00:00
|
|
|
|
|
|
|
package model
|
|
|
|
|
2017-04-26 00:15:23 +00:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
)
|
2016-04-26 14:01:46 +00:00
|
|
|
|
|
|
|
type folder struct {
|
|
|
|
stateTracker
|
2017-04-01 09:58:06 +00:00
|
|
|
|
2017-04-20 00:20:34 +00:00
|
|
|
scan folderScanner
|
|
|
|
model *Model
|
2017-04-26 00:15:23 +00:00
|
|
|
ctx context.Context
|
|
|
|
cancel context.CancelFunc
|
2017-04-20 00:20:34 +00:00
|
|
|
initialScanFinished chan struct{}
|
2016-04-26 14:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *folder) IndexUpdated() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *folder) DelayScan(next time.Duration) {
|
|
|
|
f.scan.Delay(next)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *folder) Scan(subdirs []string) error {
|
2017-04-20 00:20:34 +00:00
|
|
|
<-f.initialScanFinished
|
2016-04-26 14:01:46 +00:00
|
|
|
return f.scan.Scan(subdirs)
|
|
|
|
}
|
2017-04-26 00:15:23 +00:00
|
|
|
|
2016-04-26 14:01:46 +00:00
|
|
|
func (f *folder) Stop() {
|
2017-04-26 00:15:23 +00:00
|
|
|
f.cancel()
|
2016-04-26 14:01:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *folder) Jobs() ([]string, []string) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *folder) BringToFront(string) {}
|
|
|
|
|
2017-04-20 00:20:34 +00:00
|
|
|
func (f *folder) scanSubdirs(subDirs []string) error {
|
2017-04-26 00:15:23 +00:00
|
|
|
if err := f.model.internalScanFolderSubdirs(f.ctx, f.folderID, subDirs); err != nil {
|
2016-04-26 14:01:46 +00:00
|
|
|
// Potentially sets the error twice, once in the scanner just
|
|
|
|
// by doing a check, and once here, if the error returned is
|
|
|
|
// the same one as returned by CheckFolderHealth, though
|
|
|
|
// duplicate set is handled by setError.
|
|
|
|
f.setError(err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|