From 58185b203e0f33d7b4c63ada910b4c652a95ad9b Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 17 Mar 2025 14:20:51 -0400 Subject: [PATCH] When deleting cached depot artifacts, ensure ID is set. Otherwise the entire depot will be accidentally deleted. --- pkg/runtime/depot.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/runtime/depot.go b/pkg/runtime/depot.go index 5760edb258..b943538dff 100644 --- a/pkg/runtime/depot.go +++ b/pkg/runtime/depot.go @@ -485,10 +485,12 @@ func (d *depot) removeStaleArtifacts() error { var totalSize int64 unusedArtifacts := make([]*artifactInfo, 0) - for _, info := range d.config.Cache { + for id, info := range d.config.Cache { if !info.InUse { totalSize += info.Size - unusedArtifacts = append(unusedArtifacts, info) + unusedInfo := *info + unusedInfo.id = id // id is not set in cache since info is keyed by id + unusedArtifacts = append(unusedArtifacts, &unusedInfo) } } logging.Debug("There are %d unused artifacts totaling %.1f MB in size", len(unusedArtifacts), float64(totalSize)/float64(MB))