File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import (
2929 "path/filepath"
3030 "strconv"
3131 "strings"
32+ "sync"
3233 "time"
3334
3435 "github.com/brpaz/echozap"
@@ -218,15 +219,17 @@ func start(_ *cobra.Command, _ []string) {
218219 if err := os .MkdirAll (uiCacheDir , 0755 ); err != nil {
219220 log .Logger .Panic ("Failed to create UI cache directory" , zap .Error (err ))
220221 }
222+ cacheLock := sync.Mutex {}
221223 uiGroup .GET ("/*" , func (c echo.Context ) error {
222224 prefix := filepath .Join ("/" + strings .TrimPrefix (cfg .BaseURI , "/" ), "/ui/" )
223225 filePath := strings .TrimPrefix (strings .TrimPrefix (c .Request ().URL .Path , prefix ), "/" )
224226 fileNameMd5 := md5 .Sum ([]byte (filePath ))
225227 fileNameHash := hex .EncodeToString (fileNameMd5 [:])
226228 cachedFilePath := filepath .Join (uiCacheDir , fileNameHash )
227-
228229 modifiedContent , err := os .ReadFile (cachedFilePath )
229230 if err != nil {
231+ cacheLock .Lock ()
232+ defer cacheLock .Unlock ()
230233 file , err := ui .MainFS .Open (filePath )
231234 if err != nil {
232235 filePath = "index.html"
You can’t perform that action at this time.
0 commit comments