From 5acc4c38949361f6b0f619d7df7b580e06e92948 Mon Sep 17 00:00:00 2001 From: yusing Date: Fri, 10 Oct 2025 09:27:23 +0800 Subject: [PATCH] fix(homepage): logic error in ListAvailableIcons, ensure the cache is ready in GetHomepageMeta --- internal/homepage/list_icons.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/homepage/list_icons.go b/internal/homepage/list_icons.go index 8229c4c2..dd2865dd 100644 --- a/internal/homepage/list_icons.go +++ b/internal/homepage/list_icons.go @@ -132,7 +132,7 @@ func ListAvailableIcons() (*Cache, error) { iconsCache.RLock() if time.Since(iconsCache.LastUpdate) < updateInterval { - if len(iconsCache.Icons) == 0 { + if len(iconsCache.Icons) > 0 { iconsCache.RUnlock() return iconsCache, nil } @@ -239,9 +239,15 @@ type HomepageMeta struct { } func GetHomepageMeta(ref string) (HomepageMeta, bool) { - iconsCache.RLock() - defer iconsCache.RUnlock() - meta, ok := iconsCache.Icons[NewIconKey(IconSourceSelfhSt, ref)] + cache, err := ListAvailableIcons() + if err != nil { // sliently ignore + return HomepageMeta{}, false + } + meta, ok := cache.Icons[NewIconKey(IconSourceSelfhSt, ref)] + // these info is not available in walkxcode + // if !ok { + // meta, ok = iconsCache.Icons[NewIconKey(IconSourceWalkXCode, ref)] + // } if !ok { return HomepageMeta{}, false }