From 68b896144bc5fe2f9618c7ac614ad8bbb3177e41 Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 5 Mar 2025 12:23:11 -0500 Subject: [PATCH] Do not assume all depot artifacts are cached yet. Users upgrading State Tool will not have their artifacts cached in the depot yet. --- pkg/runtime/depot.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/runtime/depot.go b/pkg/runtime/depot.go index ce4ce3d92b..5760edb258 100644 --- a/pkg/runtime/depot.go +++ b/pkg/runtime/depot.go @@ -422,6 +422,12 @@ func (d *depot) Save() error { // Mark artifacts that are no longer used and remove the old ones. for id := range d.artifacts { if deployments, ok := d.config.Deployments[id]; !ok || len(deployments) == 0 { + if _, exists := d.config.Cache[id]; !exists { + err := d.recordUse(id) + if err != nil { + return errs.Wrap(err, "Could not update depot cache with previously used artifact") + } + } d.config.Cache[id].InUse = false logging.Debug("Artifact '%s' is no longer in use", id.String()) }