mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-23 03:11:27 +02:00
Further fixes for config file watcher
This commit is contained in:
parent
f68e5ae9ef
commit
98b4b7330e
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
|
"maps"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
@ -202,9 +203,13 @@ func configFilesWatcher(
|
|||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
|
||||||
if !bytes.Equal(lastContents, currentContents) {
|
if !maps.Equal(currentIncludes, lastIncludes) {
|
||||||
updateWatchedIncludes(lastIncludes, currentIncludes)
|
updateWatchedIncludes(lastIncludes, currentIncludes)
|
||||||
lastContents, lastIncludes = currentContents, currentIncludes
|
lastIncludes = currentIncludes
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bytes.Equal(lastContents, currentContents) {
|
||||||
|
lastContents = currentContents
|
||||||
onChange(currentContents)
|
onChange(currentContents)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,9 +235,12 @@ func configFilesWatcher(
|
|||||||
if event.Has(fsnotify.Write) {
|
if event.Has(fsnotify.Write) {
|
||||||
debouncedCallback()
|
debouncedCallback()
|
||||||
} else if event.Has(fsnotify.Remove) {
|
} else if event.Has(fsnotify.Remove) {
|
||||||
|
func() {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
delete(lastIncludes, event.Name)
|
defer mu.Unlock()
|
||||||
mu.Unlock()
|
fileAbsPath, _ := filepath.Abs(event.Name)
|
||||||
|
delete(lastIncludes, fileAbsPath)
|
||||||
|
}()
|
||||||
|
|
||||||
debouncedCallback()
|
debouncedCallback()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user