Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • oss/libraries/go/application/configuration
1 result
Select Git revision
Show changes
Commits on Source (3)
<a name="v1.11.1"></a>
## [v1.11.1] - 2022-10-23
### Bug Fixes
- fix monitor directories not files
<a name="v1.11.0"></a> <a name="v1.11.0"></a>
## [v1.11.0] - 2022-10-23 ## [v1.11.0] - 2022-10-23
### Add Features ### Add Features
...@@ -113,6 +119,7 @@ ...@@ -113,6 +119,7 @@
<a name="v1.0.0"></a> <a name="v1.0.0"></a>
## v1.0.0 - 2022-09-18 ## v1.0.0 - 2022-09-18
[v1.11.1]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.11.0...v1.11.1
[v1.11.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.10.0...v1.11.0 [v1.11.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.10.0...v1.11.0
[v1.10.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.9.0...v1.10.0 [v1.10.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.9.0...v1.10.0
[v1.9.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.8.0...v1.9.0 [v1.9.0]: https://gitlab.schukai.com/oss/libraries/go/application/configuration/compare/v1.8.0...v1.9.0
......
...@@ -95,7 +95,7 @@ func (s *Settings[C]) importFiles() { ...@@ -95,7 +95,7 @@ func (s *Settings[C]) importFiles() {
s.fileWatch.Lock() s.fileWatch.Lock()
// new files may have been added // new files may have been added
tmpWatchList := make(map[string]string) tmpWatchList := make(map[string]bool)
defer func() { defer func() {
s.fileWatch.watchList = tmpWatchList s.fileWatch.watchList = tmpWatchList
...@@ -123,7 +123,7 @@ func (s *Settings[C]) importFiles() { ...@@ -123,7 +123,7 @@ func (s *Settings[C]) importFiles() {
s.importStream(reader{s.files.format, r}) s.importStream(reader{s.files.format, r})
f.Close() f.Close()
tmpWatchList[fn] = fn tmpWatchList[fn] = true
} }
...@@ -138,7 +138,7 @@ func (s *Settings[C]) importFiles() { ...@@ -138,7 +138,7 @@ func (s *Settings[C]) importFiles() {
s.importStream(reader{f.format, r}) s.importStream(reader{f.format, r})
r.Close() r.Close()
tmpWatchList[f.path] = f.path tmpWatchList[f.path] = true
} }
} }
......
{"version":"1.11.0"} {"version":"1.11.1"}
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
type fileWatch struct { type fileWatch struct {
sync.Mutex sync.Mutex
watcher *fsnotify.Watcher watcher *fsnotify.Watcher
watchList map[string]string watchList map[string]bool
cancelWatch chan bool cancelWatch chan bool
onWatch bool onWatch bool
} }
......
...@@ -5,6 +5,8 @@ package configuration ...@@ -5,6 +5,8 @@ package configuration
import ( import (
"github.com/fsnotify/fsnotify" "github.com/fsnotify/fsnotify"
"os"
"path"
) )
func (s *Settings[C]) initWatch() *Settings[C] { func (s *Settings[C]) initWatch() *Settings[C] {
...@@ -97,7 +99,19 @@ func (s *Settings[C]) Watch() *Settings[C] { ...@@ -97,7 +99,19 @@ 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 file := range s.fileWatch.watchList {
err := s.fileWatch.watcher.Add(file)
fileInfo, err := os.Stat(file)
if err != nil {
s.errors = append(s.errors, err)
continue
}
if fileInfo.IsDir() {
err = s.fileWatch.watcher.Add(file)
} else {
err = s.fileWatch.watcher.Add(path.Dir(file))
}
if err != nil { if err != nil {
s.errors = append(s.errors, err) s.errors = append(s.errors, err)
} }
...@@ -119,6 +133,11 @@ func (s *Settings[C]) Watch() *Settings[C] { ...@@ -119,6 +133,11 @@ func (s *Settings[C]) Watch() *Settings[C] {
return return
} }
_, exist := s.fileWatch.watchList[event.Name]
if !exist {
continue
}
if event.Op&fsnotify.Write == fsnotify.Write { if event.Op&fsnotify.Write == fsnotify.Write {
s.Import() s.Import()
} else if event.Op&fsnotify.Remove == fsnotify.Remove { } else if event.Op&fsnotify.Remove == fsnotify.Remove {
......