mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2026-08-16 17:16:02 +00:00
actually use bool as a type for caches
Semms this code was never actually used after refactoring, now it is again
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user