MCPcopy
hub / github.com/spicetify/cli / Watch

Function Watch

src/utils/watcher.go:22–47  ·  view source on GitHub ↗

Watch .

(fileList []string, callbackEach func(fileName string, err error), callbackAfter func())

Source from the content-addressed store, hash-verified

20
21// Watch .
22func Watch(fileList []string, callbackEach func(fileName string, err error), callbackAfter func()) {
23 var cache = map[string][]byte{}
24
25 for {
26 finalCallback := false
27 for _, v := range fileList {
28 curr, err := os.ReadFile(v)
29 if err != nil {
30 callbackEach(v, err)
31 continue
32 }
33
34 if !bytes.Equal(cache[v], curr) {
35 callbackEach(v, nil)
36 cache[v] = curr
37 finalCallback = true
38 }
39 }
40
41 if callbackAfter != nil && finalCallback {
42 callbackAfter()
43 }
44
45 time.Sleep(INTERVAL)
46 }
47}
48
49// WatchRecursive .
50func WatchRecursive(root string, callbackEach func(fileName string, err error), callbackAfter func()) {

Callers 3

WatchFunction · 0.92
WatchExtensionsFunction · 0.92
WatchCustomAppFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected