Skip to content

A self-hosted dashboard that puts all your feeds in one place

Move log outside of func

Svilen Markovb3e73ce86af0
diff --git a/internal/glance/embed.go b/internal/glance/embed.go
index 65b1a72..7bb07c9 100644
--- a/internal/glance/embed.go
+++ b/internal/glance/embed.go
@@ -20,9 +20,17 @@ var _templateFS embed.FS
var staticFS, _ = fs.Sub(_staticFS, "static")
var templateFS, _ = fs.Sub(_templateFS, "templates")
-var staticFSHash = computeFSHash(staticFS)
+var staticFSHash = func() string {
+ hash, err := computeFSHash(staticFS)
+ if err != nil {
+ log.Printf("Could not compute static assets cache key: %v", err)
+ return strconv.FormatInt(time.Now().Unix(), 10)
+ }
+
+ return hash
+}()
-func computeFSHash(files fs.FS) string {
+func computeFSHash(files fs.FS) (string, error) {
hash := md5.New()
err := fs.WalkDir(files, ".", func(path string, d fs.DirEntry, err error) error {
@@ -46,10 +54,9 @@ func computeFSHash(files fs.FS) string {
return nil
})
- if err == nil {
- return hex.EncodeToString(hash.Sum(nil))[:10]
+ if err != nil {
+ return "", err
}
- log.Printf("Could not compute assets cache: %v", err)
- return strconv.FormatInt(time.Now().Unix(), 10)
+ return hex.EncodeToString(hash.Sum(nil))[:10], nil
}