MCPcopy
hub / github.com/docker/compose / Start

Method Start

pkg/watch/watcher_naive.go:57–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func (d *naiveNotify) Start() error {
58 if len(d.notifyList) == 0 {
59 return nil
60 }
61
62 pathsToWatch := []string{}
63 for path := range d.notifyList {
64 pathsToWatch = append(pathsToWatch, path)
65 }
66
67 pathsToWatch, err := greatestExistingAncestors(pathsToWatch)
68 if err != nil {
69 return err
70 }
71 if d.isWatcherRecursive {
72 pathsToWatch = pathutil.EncompassingPaths(pathsToWatch)
73 }
74
75 for _, name := range pathsToWatch {
76 fi, err := os.Stat(name)
77 if err != nil && !os.IsNotExist(err) {
78 return fmt.Errorf("notify.Add(%q): %w", name, err)
79 }
80
81 // if it's a file that doesn't exist,
82 // we should have caught that above, let's just skip it.
83 if os.IsNotExist(err) {
84 continue
85 }
86
87 if fi.IsDir() {
88 err = d.watchRecursively(name)
89 if err != nil {
90 return fmt.Errorf("notify.Add(%q): %w", name, err)
91 }
92 } else {
93 err = d.add(filepath.Dir(name))
94 if err != nil {
95 return fmt.Errorf("notify.Add(%q): %w", filepath.Dir(name), err)
96 }
97 }
98 }
99
100 go d.loop()
101
102 return nil
103}
104
105func (d *naiveNotify) watchRecursively(dir string) error {
106 if d.isWatcherRecursive {

Callers

nothing calls this directly

Calls 5

watchRecursivelyMethod · 0.95
addMethod · 0.95
loopMethod · 0.95
DirMethod · 0.45

Tested by

no test coverage detected