From 0e083c1aea0e23b594b40c2afc26d960b844eb49 Mon Sep 17 00:00:00 2001 From: Gareth George Date: Tue, 7 Jan 2025 20:46:40 -0800 Subject: [PATCH] fix: rare race condition in etag cache when serving webui --- webui/webui.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webui/webui.go b/webui/webui.go index 0092a5b8..3e92dcbd 100644 --- a/webui/webui.go +++ b/webui/webui.go @@ -8,12 +8,16 @@ import ( "io/fs" "net/http" "strings" + "sync" "time" ) +var etagCacheMu sync.Mutex var etagCache = make(map[string]string) func calcEtag(path string, data []byte) string { + etagCacheMu.Lock() + defer etagCacheMu.Unlock() etag, ok := etagCache[path] if ok { return etag