mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
improve initialization flow
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/yusing/go-proxy/internal/common"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/utils"
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
)
|
||||
|
||||
type GitHubContents struct { //! keep this, may reuse in future
|
||||
@@ -66,10 +65,10 @@ func InitIconListCache() {
|
||||
logging.Error().Err(err).Msg("failed to load icon list cache config")
|
||||
} else if stats, err := os.Stat(common.IconListCachePath); err == nil {
|
||||
lastUpdate = stats.ModTime()
|
||||
logging.Info().Msgf("icon list cache loaded (%d icons, %d display names), last updated at %s",
|
||||
len(iconsCache.IconList),
|
||||
len(iconsCache.DisplayNames),
|
||||
strutils.FormatTime(lastUpdate))
|
||||
logging.Info().
|
||||
Int("icons", len(iconsCache.IconList)).
|
||||
Int("display_names", len(iconsCache.DisplayNames)).
|
||||
Msg("icon list cache loaded")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +85,15 @@ func ListAvailableIcons() (*Cache, error) {
|
||||
iconsCahceMu.Lock()
|
||||
defer iconsCahceMu.Unlock()
|
||||
|
||||
logging.Info().Msg("updating icon data")
|
||||
icons, err := fetchIconData()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logging.Info().Msg("icons list updated")
|
||||
logging.Info().
|
||||
Int("icons", len(icons.IconList)).
|
||||
Int("display_names", len(icons.DisplayNames)).
|
||||
Msg("icons list updated")
|
||||
|
||||
iconsCache = icons
|
||||
lastUpdate = time.Now()
|
||||
|
||||
Reference in New Issue
Block a user