fix favicon on non http 200

This commit is contained in:
yusing 2025-01-13 00:52:07 +08:00
parent 1abd1e257f
commit d887a37f60

View file

@ -131,8 +131,10 @@ func getIconAbsolute(url string) ([]byte, int, string) {
} }
resp, err := U.Get(url) resp, err := U.Get(url)
if err != nil { if err != nil || resp.StatusCode != http.StatusOK {
storeIconCache(url, nil) if err == nil {
err = errors.New(resp.Status)
}
logging.Error().Err(err). logging.Error().Err(err).
Str("url", url). Str("url", url).
Msg("failed to get icon") Msg("failed to get icon")
@ -142,7 +144,6 @@ func getIconAbsolute(url string) ([]byte, int, string) {
defer resp.Body.Close() defer resp.Body.Close()
icon, err = io.ReadAll(resp.Body) icon, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
// storeIconCache(url, nil) // can retry
logging.Error().Err(err). logging.Error().Err(err).
Str("url", url). Str("url", url).
Msg("failed to read icon") Msg("failed to read icon")