aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-23 01:31:13 +0900
committerOphestra <cat@gensokyo.uk>2026-05-23 01:31:13 +0900
commitf5e9a0c04e0373ac527f180bb9f9ec010732038f (patch)
treec32497dd8de9ebc215b614788df5f13c9e7e59da
parent3bd4ef616ceaa4f064d7f992706d0a0512119548 (diff)
internal/pkg: destroy new substitution status on fault
This avoids leaving behind the substitution status path of a faulted cure. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/pkg/pkg.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go
index d2565c37..883798a4 100644
--- a/internal/pkg/pkg.go
+++ b/internal/pkg/pkg.go
@@ -155,7 +155,7 @@ type TContext struct {
// Target [Artifact] encoded identifier.
ids string
// Pathname status was created at.
- statusPath *check.Absolute
+ statusPath, statusSPath *check.Absolute
// File statusHeader and logs are written to.
status *os.File
// Error value during prepareStatus.
@@ -258,6 +258,11 @@ func (t *TContext) destroy(errP *error) {
), 10),
).String(),
))
+ if t.statusSPath != nil {
+ t.cache.checksumMu.Lock()
+ *errP = errors.Join(*errP, os.Remove(t.statusSPath.String()))
+ t.cache.checksumMu.Unlock()
+ }
}
t.status = nil
}
@@ -1957,7 +1962,7 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
t := TContext{
c.base.Append(dirWork, ids),
c.base.Append(dirTemp, ids),
- ids, nil, nil, nil,
+ ids, nil, nil, nil, nil,
common{ctx, c},
}
switch ca := a.(type) {
@@ -2049,13 +2054,19 @@ func (c *Cache) cure(a Artifact, curesExempt bool) (
}
err = ca.Cure(&f)
if err == nil && f.status != nil {
+ statusS := c.base.Append(
+ dirStatus,
+ substitutes,
+ )
+ c.checksumMu.Lock()
err = os.Link(c.base.Append(
dirStatus,
ids,
- ).String(), c.base.Append(
- dirStatus,
- substitutes,
- ).String())
+ ).String(), statusS.String())
+ c.checksumMu.Unlock()
+ if err == nil {
+ f.statusSPath = statusS
+ }
}
c.exitCure(a, curesExempt)
if err != nil {