internal/pkg: destroy new substitution status on fault
All checks were successful
Test / Create distribution (push) Successful in 1m8s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 3m56s
Test / Hakurei (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 5m44s
Test / Hakurei (race detector) (push) Successful in 7m10s
Test / Flake checks (push) Successful in 2m30s
All checks were successful
Test / Create distribution (push) Successful in 1m8s
Test / Sandbox (push) Successful in 2m54s
Test / ShareFS (push) Successful in 3m56s
Test / Hakurei (push) Successful in 4m5s
Test / Sandbox (race detector) (push) Successful in 5m44s
Test / Hakurei (race detector) (push) Successful in 7m10s
Test / Flake checks (push) Successful in 2m30s
This avoids leaving behind the substitution status path of a faulted cure. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user