From 40886ba487172c909dc78a103040f4fee7cf8e6b Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 2 Oct 2024 06:55:31 -0400 Subject: [PATCH] Only cache completed build plans. --- pkg/platform/model/buildplanner/build.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/platform/model/buildplanner/build.go b/pkg/platform/model/buildplanner/build.go index 8763ec6506..f3c38cd9bb 100644 --- a/pkg/platform/model/buildplanner/build.go +++ b/pkg/platform/model/buildplanner/build.go @@ -78,12 +78,14 @@ func (b *BuildPlanner) FetchCommit(commitID strfmt.UUID, owner, project string, } return nil, err } - respBytes, err := json.Marshal(resp) - if err != nil { - return nil, errs.Wrap(err, "failed to marshal cache") - } - if err := b.cache.SetCache(cacheKey, string(respBytes), fetchCommitCacheExpiry); err != nil { - return nil, errs.Wrap(err, "failed to set cache") + if resp.Project.Commit.Build.Status == raw.Completed { + respBytes, err := json.Marshal(resp) + if err != nil { + return nil, errs.Wrap(err, "failed to marshal cache") + } + if err := b.cache.SetCache(cacheKey, string(respBytes), fetchCommitCacheExpiry); err != nil { + return nil, errs.Wrap(err, "failed to set cache") + } } }