Skip to content

Commit acdcfcc

Browse files
authored
Fix cache bug (go-gitea#30510)
Cache cannot be disabled from v1.22. So it still maybe `nil` in v1.21, we have to check whether cache is `nil`.
1 parent 727b191 commit acdcfcc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

services/repository/commitstatus/commitstatus.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ type commitStatusCacheValue struct {
3232

3333
func getCommitStatusCache(repoID int64, branchName string) *commitStatusCacheValue {
3434
c := cache.GetCache()
35+
if c == nil {
36+
return nil
37+
}
3538
statusStr, ok := c.Get(getCacheKey(repoID, branchName)).(string)
3639
if ok && statusStr != "" {
3740
var cv commitStatusCacheValue
@@ -48,6 +51,9 @@ func getCommitStatusCache(repoID int64, branchName string) *commitStatusCacheVal
4851

4952
func updateCommitStatusCache(repoID int64, branchName string, state api.CommitStatusState, targetURL string) error {
5053
c := cache.GetCache()
54+
if c == nil {
55+
return nil
56+
}
5157
bs, err := json.Marshal(commitStatusCacheValue{
5258
State: state.String(),
5359
TargetURL: targetURL,

0 commit comments

Comments
 (0)