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