aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-06 04:24:54 +0900
committerOphestra <cat@gensokyo.uk>2026-01-06 04:24:54 +0900
commit8efffd72f4c5a0f241075fd13e4d07d71fd7fde8 (patch)
treed80c6d035df7677b2e99f1480c01cafed567cb09 /internal
parent86ad8b72aa19f348f5e1a48c79c30accc86fcaa1 (diff)
internal/pkg: destroy temp during deferred cleanup
This avoids missing the cleanup when cure returns an error. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/pkg.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index 85a9f823..39563c90 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -181,7 +181,7 @@ type Kind uint64
const (
// KindHTTPGet is the kind of [Artifact] returned by [NewHTTPGet].
KindHTTPGet Kind = iota
- // KindTar is the kind of artifact returned by [NewTar].
+ // KindTar is the kind of [Artifact] returned by [NewTar].
KindTar
)
@@ -829,6 +829,11 @@ func (c *Cache) Cure(a Artifact) (
temp: c.base.Append(dirTemp, ids),
}
defer func() {
+ if chmodErr, removeErr := removeAll(cc.temp); chmodErr != nil || removeErr != nil {
+ err = errors.Join(err, chmodErr, removeErr)
+ return
+ }
+
if err != nil {
chmodErr, removeErr := removeAll(cc.work)
if chmodErr != nil || removeErr != nil {
@@ -844,11 +849,6 @@ func (c *Cache) Cure(a Artifact) (
return
}
cc.cache = nil
- if chmodErr, removeErr := removeAll(cc.temp); chmodErr != nil || removeErr != nil {
- err = errors.Join(err, chmodErr, removeErr)
- return
- }
-
var fi os.FileInfo
if fi, err = os.Lstat(cc.work.String()); err != nil {
if errors.Is(err, os.ErrNotExist) {