MCPcopy
hub / github.com/wavetermdev/waveterm / GetWatcher

Function GetWatcher

pkg/wconfig/filewatcher.go:37–62  ·  view source on GitHub ↗

GetWatcher returns the singleton instance of the Watcher

()

Source from the content-addressed store, hash-verified

35
36// GetWatcher returns the singleton instance of the Watcher
37func GetWatcher() *Watcher {
38 once.Do(func() {
39 watcher, err := fsnotify.NewWatcher()
40 if err != nil {
41 log.Printf("failed to create file watcher: %v", err)
42 return
43 }
44 configDirAbsPath := wavebase.GetWaveConfigDir()
45 log.Printf("create config watcher, configdir=%q", configDirAbsPath)
46 instance = &Watcher{watcher: watcher}
47 err = instance.watcher.Add(configDirAbsPath)
48 const failedStr = "failed to add path %s to watcher: %v"
49 if err != nil {
50 log.Printf(failedStr, configDirAbsPath, err)
51 }
52
53 subdirs := GetConfigSubdirs()
54 for _, dir := range subdirs {
55 err = instance.watcher.Add(dir)
56 if err != nil && !os.IsNotExist(err) {
57 log.Printf(failedStr, dir, err)
58 }
59 }
60 })
61 return instance
62}
63
64func (w *Watcher) Start() {
65 w.mutex.Lock()

Callers 15

GetFullConfigCommandMethod · 0.92
FindGitBashCommandMethod · 0.92
CheckGoVersionCommandMethod · 0.92
GetTsunamiScaffoldPathFunction · 0.92
ResolveGoFmtPathFunction · 0.92
ConnectToClientFunction · 0.92
getConnWshSettingsMethod · 0.92
getConnectionConfigMethod · 0.92
IsTelemetryEnabledFunction · 0.92
IsAutoUpdateEnabledFunction · 0.92

Calls 2

GetWaveConfigDirFunction · 0.92
GetConfigSubdirsFunction · 0.85

Tested by

no test coverage detected