folder.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. package model
  7. import (
  8. "context"
  9. "time"
  10. )
  11. type folder struct {
  12. stateTracker
  13. scan folderScanner
  14. model *Model
  15. ctx context.Context
  16. cancel context.CancelFunc
  17. initialScanFinished chan struct{}
  18. }
  19. func (f *folder) IndexUpdated() {
  20. }
  21. func (f *folder) DelayScan(next time.Duration) {
  22. f.scan.Delay(next)
  23. }
  24. func (f *folder) Scan(subdirs []string) error {
  25. <-f.initialScanFinished
  26. return f.scan.Scan(subdirs)
  27. }
  28. func (f *folder) Stop() {
  29. f.cancel()
  30. }
  31. func (f *folder) Jobs() ([]string, []string) {
  32. return nil, nil
  33. }
  34. func (f *folder) BringToFront(string) {}
  35. func (f *folder) scanSubdirs(subDirs []string) error {
  36. if err := f.model.internalScanFolderSubdirs(f.ctx, f.folderID, subDirs); err != nil {
  37. // Potentially sets the error twice, once in the scanner just
  38. // by doing a check, and once here, if the error returned is
  39. // the same one as returned by CheckFolderHealth, though
  40. // duplicate set is handled by setError.
  41. f.setError(err)
  42. return err
  43. }
  44. return nil
  45. }