Fix: Do not spam events when file is gone for longer

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-05-24 18:00:50 +02:00
parent 50f1e01e3b
commit 5339e866e5
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -19,6 +19,7 @@ const (
func watchConfigChanges(filename string, evt chan configChangeEvent) { func watchConfigChanges(filename string, evt chan configChangeEvent) {
var ( var (
available bool
initialized bool initialized bool
size int64 size int64
modTime time.Time modTime time.Time
@ -31,7 +32,10 @@ func watchConfigChanges(filename string, evt chan configChangeEvent) {
// Fine // Fine
case os.IsNotExist(err): case os.IsNotExist(err):
evt <- configChangeEventNotExist if available {
evt <- configChangeEventNotExist
}
available = false
continue continue
default: default:
@ -43,6 +47,7 @@ func watchConfigChanges(filename string, evt chan configChangeEvent) {
evt <- configChangeEventModified evt <- configChangeEventModified
} }
available = true
initialized = true initialized = true
size = info.Size() size = info.Size()
modTime = info.ModTime() modTime = info.ModTime()