folder.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 http://mozilla.org/MPL/2.0/.
  6. package model
  7. import "time"
  8. type folder struct {
  9. stateTracker
  10. scan folderScanner
  11. model *Model
  12. stop chan struct{}
  13. }
  14. func (f *folder) IndexUpdated() {
  15. }
  16. func (f *folder) DelayScan(next time.Duration) {
  17. f.scan.Delay(next)
  18. }
  19. func (f *folder) Scan(subdirs []string) error {
  20. return f.scan.Scan(subdirs)
  21. }
  22. func (f *folder) Stop() {
  23. close(f.stop)
  24. }
  25. func (f *folder) Jobs() ([]string, []string) {
  26. return nil, nil
  27. }
  28. func (f *folder) BringToFront(string) {}
  29. func (f *folder) scanSubdirsIfHealthy(subDirs []string) error {
  30. if err := f.model.CheckFolderHealth(f.folderID); err != nil {
  31. l.Infoln("Skipping folder", f.folderID, "scan due to folder error:", err)
  32. return err
  33. }
  34. l.Debugln(f, "Scanning subdirectories")
  35. if err := f.model.internalScanFolderSubdirs(f.folderID, subDirs); err != nil {
  36. // Potentially sets the error twice, once in the scanner just
  37. // by doing a check, and once here, if the error returned is
  38. // the same one as returned by CheckFolderHealth, though
  39. // duplicate set is handled by setError.
  40. f.setError(err)
  41. return err
  42. }
  43. return nil
  44. }