mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 09:48:32 +02:00
fix(homepage): logic error in ListAvailableIcons, ensure the cache is ready in GetHomepageMeta
This commit is contained in:
@@ -132,7 +132,7 @@ func ListAvailableIcons() (*Cache, error) {
|
|||||||
|
|
||||||
iconsCache.RLock()
|
iconsCache.RLock()
|
||||||
if time.Since(iconsCache.LastUpdate) < updateInterval {
|
if time.Since(iconsCache.LastUpdate) < updateInterval {
|
||||||
if len(iconsCache.Icons) == 0 {
|
if len(iconsCache.Icons) > 0 {
|
||||||
iconsCache.RUnlock()
|
iconsCache.RUnlock()
|
||||||
return iconsCache, nil
|
return iconsCache, nil
|
||||||
}
|
}
|
||||||
@@ -239,9 +239,15 @@ type HomepageMeta struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetHomepageMeta(ref string) (HomepageMeta, bool) {
|
func GetHomepageMeta(ref string) (HomepageMeta, bool) {
|
||||||
iconsCache.RLock()
|
cache, err := ListAvailableIcons()
|
||||||
defer iconsCache.RUnlock()
|
if err != nil { // sliently ignore
|
||||||
meta, ok := iconsCache.Icons[NewIconKey(IconSourceSelfhSt, ref)]
|
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 {
|
if !ok {
|
||||||
return HomepageMeta{}, false
|
return HomepageMeta{}, false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user