diff options
author | Valery Piashchynski <[email protected]> | 2020-12-16 21:52:52 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-16 21:52:52 +0300 |
commit | a5431a6dd0dc1d803bd7cfa2bbcb017d85d0999e (patch) | |
tree | 873249c7bf427fec21dba377a7f84caaec853e87 /plugins/reload | |
parent | dd0238723a153646631ba0a8c2577d74fce61214 (diff) |
Use ERROR log level everywhere. Remove unused code from Reload plugin
Diffstat (limited to 'plugins/reload')
-rw-r--r-- | plugins/reload/samefile.go | 9 | ||||
-rw-r--r-- | plugins/reload/samefile_windows.go | 12 | ||||
-rw-r--r-- | plugins/reload/watcher.go | 24 |
3 files changed, 3 insertions, 42 deletions
diff --git a/plugins/reload/samefile.go b/plugins/reload/samefile.go deleted file mode 100644 index 80df0431..00000000 --- a/plugins/reload/samefile.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !windows - -package reload - -import "os" - -func sameFile(fi1, fi2 os.FileInfo) bool { - return os.SameFile(fi1, fi2) -} diff --git a/plugins/reload/samefile_windows.go b/plugins/reload/samefile_windows.go deleted file mode 100644 index 5f70d327..00000000 --- a/plugins/reload/samefile_windows.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build windows - -package reload - -import "os" - -func sameFile(fi1, fi2 os.FileInfo) bool { - return fi1.ModTime() == fi2.ModTime() && - fi1.Size() == fi2.Size() && - fi1.Mode() == fi2.Mode() && - fi1.IsDir() == fi2.IsDir() -} diff --git a/plugins/reload/watcher.go b/plugins/reload/watcher.go index fff11f32..55e1d9d5 100644 --- a/plugins/reload/watcher.go +++ b/plugins/reload/watcher.go @@ -147,6 +147,7 @@ func ConvertIgnored(ignored []string) (map[string]struct{}, error) { // pass map from outside func (w *Watcher) retrieveFilesSingle(serviceName, path string) (map[string]os.FileInfo, error) { + const op = errors.Op("retrieve") stat, err := os.Stat(path) if err != nil { return nil, err @@ -340,29 +341,9 @@ func (w *Watcher) pollEvents(serviceName string, files map[string]os.FileInfo) { } } - // Check for renames and moves. - for path1 := range removes { - for path2 := range creates { - if sameFile(removes[path1], creates[path2]) { - e := Event{ - Path: path2, - Info: creates[path2], - service: serviceName, - } - - // remove initial path - delete(w.watcherConfigs[serviceName].Files, path1) - // update with new - w.watcherConfigs[serviceName].Files[path2] = creates[path2] - - w.log.Debug("file was renamed/moved", "old path", path1, "new path", path2, "name", creates[path2].Name(), "size", creates[path2].Size()) - w.Event <- e - } - } - } - // Send all the remaining create and remove events. for pth := range creates { + // add file to the plugin watch files w.watcherConfigs[serviceName].Files[pth] = creates[pth] w.log.Debug("file was added to watcher", "path", pth, "name", creates[pth].Name(), "size", creates[pth].Size()) @@ -374,6 +355,7 @@ func (w *Watcher) pollEvents(serviceName string, files map[string]os.FileInfo) { } for pth := range removes { + // delete path from the config delete(w.watcherConfigs[serviceName].Files, pth) w.log.Debug("file was removed from watcher", "path", pth, "name", removes[pth].Name(), "size", removes[pth].Size()) |