fix(cache): use correct duration strings
Some checks are pending
Code QL / code-ql (push) Waiting to run
Release / changelog (push) Waiting to run
Release / artifacts (push) Blocked by required conditions

resolves #5814
resolves #5812
This commit is contained in:
Jan De Dobbeleer 2024-11-05 08:20:21 +01:00 committed by Jan De Dobbeleer
parent 2a3b26f9fd
commit 52c39b8d30
6 changed files with 9 additions and 6 deletions

View file

@ -9,6 +9,8 @@ type Duration string
const (
INFINITE = Duration("infinite")
ONEWEEK = Duration("168h")
ONEDAY = Duration("24h")
TWOYEARS = Duration("17520h")
)
func (d Duration) Seconds() int {

View file

@ -50,7 +50,7 @@ var toggleCmd = &cobra.Command{
newToggles = append(newToggles, segment)
}
env.Session().Set(cache.TOGGLECACHE, strings.Join(newToggles, ","), "1day")
env.Session().Set(cache.TOGGLECACHE, strings.Join(newToggles, ","), cache.ONEDAY)
},
}

View file

@ -78,7 +78,7 @@ func setCachedFontData(assets []*Asset) {
return
}
environment.Cache().Set(cache.FONTLISTCACHE, string(data), "1day")
environment.Cache().Set(cache.FONTLISTCACHE, string(data), cache.ONEDAY)
}
func CascadiaCode() ([]*Asset, error) {

View file

@ -91,7 +91,7 @@ func (o *OAuthRequest) refreshToken(refreshToken string) (string, error) {
// add tokens to cache
o.Env.Cache().Set(o.AccessTokenKey, tokens.AccessToken, cache.ToDuration(tokens.ExpiresIn))
o.Env.Cache().Set(o.RefreshTokenKey, tokens.RefreshToken, "2years")
o.Env.Cache().Set(o.RefreshTokenKey, tokens.RefreshToken, cache.TWOYEARS)
return tokens.AccessToken, nil
}

View file

@ -591,7 +591,7 @@ func (term *Terminal) saveTemplateCache() {
templateCache, err := json.Marshal(tmplCache)
if err == nil {
term.sessionCache.Set(cache.TEMPLATECACHE, string(templateCache), "1day")
term.sessionCache.Set(cache.TEMPLATECACHE, string(templateCache), cache.ONEDAY)
}
}
@ -757,7 +757,7 @@ func (term *Terminal) setPromptCount() {
// Only update the count if we're generating a primary prompt.
if term.CmdFlags.Primary {
count++
term.Session().Set(cache.PROMPTCOUNTCACHE, strconv.Itoa(count), "1day")
term.Session().Set(cache.PROMPTCOUNTCACHE, strconv.Itoa(count), cache.ONEDAY)
}
term.CmdFlags.PromptCount = count

View file

@ -6,6 +6,7 @@ import (
"time"
"github.com/jandedobbeleer/oh-my-posh/src/build"
"github.com/jandedobbeleer/oh-my-posh/src/cache"
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
"github.com/jandedobbeleer/oh-my-posh/src/runtime/http"
)
@ -83,7 +84,7 @@ func Notice(env runtime.Environment, force bool) (string, bool) {
return "", false
}
env.Cache().Set(CACHEKEY, latest, "1week")
env.Cache().Set(CACHEKEY, latest, cache.ONEWEEK)
version := fmt.Sprintf("v%s", build.Version)
if latest == version {