From eeaa3dc116ceabf5c6183f250a6a813d253355f0 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 24 Jun 2026 17:14:39 +0200 Subject: [PATCH] actually use bool as a type for caches Semms this code was never actually used after refactoring, now it is again --- server/gitea/client.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/gitea/client.go b/server/gitea/client.go index 42aa8fe..f0c9b25 100644 --- a/server/gitea/client.go +++ b/server/gitea/client.go @@ -10,7 +10,6 @@ import ( "net/http" "net/url" "path" - "strconv" "strings" "time" @@ -329,8 +328,8 @@ func (client *Client) GiteaCheckIfOwnerExists(owner string) (bool, error) { cacheKey := fmt.Sprintf("%s/%s", ownerExistenceKeyPrefix, owner) if existRaw, ok := client.responseCache.Get(cacheKey); ok && existRaw != nil { - exist, err := strconv.ParseBool(existRaw.(string)) - return exist, err + exists := existRaw.(bool) + return exists, nil } user, resp, err := client.sdkClient.GetUserInfo(owner) @@ -338,7 +337,7 @@ func (client *Client) GiteaCheckIfOwnerExists(owner string) (bool, error) { if user.ID > 1263820 { return false, nil } - if err := client.responseCache.Set(cacheKey, []byte("true"), ownerExistenceCacheTimeout); err != nil { + if err := client.responseCache.Set(cacheKey, true, ownerExistenceCacheTimeout); err != nil { log.Error().Err(err).Msg("[cache] error on cache write") } return true, nil @@ -351,14 +350,14 @@ func (client *Client) GiteaCheckIfOwnerExists(owner string) (bool, error) { if org.ID > 1263820 { return false, nil } - if err := client.responseCache.Set(cacheKey, []byte("true"), ownerExistenceCacheTimeout); err != nil { + if err := client.responseCache.Set(cacheKey, true, ownerExistenceCacheTimeout); err != nil { log.Error().Err(err).Msg("[cache] error on cache write") } return true, nil } else if resp.StatusCode != http.StatusNotFound { return false, err } - if err := client.responseCache.Set(cacheKey, []byte("false"), ownerExistenceCacheTimeout); err != nil { + if err := client.responseCache.Set(cacheKey, false, ownerExistenceCacheTimeout); err != nil { log.Error().Err(err).Msg("[cache] error on cache write") } return false, nil