Skip to content
Snippets Groups Projects
Verified Commit b83d77aa authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix deleted files must not be removed from the watch list

parent 3bd7d419
No related branches found
No related tags found
No related merge requests found
...@@ -94,11 +94,7 @@ func (s *Settings[C]) importFiles() { ...@@ -94,11 +94,7 @@ func (s *Settings[C]) importFiles() {
s.fileWatch.Lock() s.fileWatch.Lock()
// new files may have been added
tmpWatchList := make(map[string]bool)
defer func() { defer func() {
s.fileWatch.watchList = tmpWatchList
s.fileWatch.Unlock() s.fileWatch.Unlock()
}() }()
...@@ -122,9 +118,6 @@ func (s *Settings[C]) importFiles() { ...@@ -122,9 +118,6 @@ func (s *Settings[C]) importFiles() {
r := (io.Reader)(f) r := (io.Reader)(f)
s.importStream(reader{s.files.format, r}) s.importStream(reader{s.files.format, r})
f.Close() f.Close()
tmpWatchList[fn] = true
} }
for _, f := range s.files.files { for _, f := range s.files.files {
...@@ -135,10 +128,11 @@ func (s *Settings[C]) importFiles() { ...@@ -135,10 +128,11 @@ func (s *Settings[C]) importFiles() {
r.Close() r.Close()
continue continue
} }
s.importStream(reader{f.format, r}) s.importStream(reader{f.format, r})
r.Close() r.Close()
tmpWatchList[f.path] = true
} }
} }
......
...@@ -98,18 +98,18 @@ func (s *Settings[C]) Watch() *Settings[C] { ...@@ -98,18 +98,18 @@ func (s *Settings[C]) Watch() *Settings[C] {
} }
// add all files to the watch list // add all files to the watch list
for file := range s.fileWatch.watchList { for filePath := range s.fileWatch.watchList {
fileInfo, err := os.Stat(file) fileInfo, err := os.Stat(filePath)
if err != nil { if err != nil {
s.errors = append(s.errors, err) s.errors = append(s.errors, err)
continue continue
} }
if fileInfo.IsDir() { if fileInfo.IsDir() {
err = s.fileWatch.watcher.Add(file) err = s.fileWatch.watcher.Add(filePath)
} else { } else {
err = s.fileWatch.watcher.Add(path.Dir(file)) err = s.fileWatch.watcher.Add(path.Dir(filePath))
} }
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment