internal/pkg: destroy temp during deferred cleanup
All checks were successful
Test / Create distribution (push) Successful in 43s
Test / Sandbox (push) Successful in 2m34s
Test / Hakurei (push) Successful in 3m37s
Test / ShareFS (push) Successful in 3m42s
Test / Hpkg (push) Successful in 4m18s
Test / Sandbox (race detector) (push) Successful in 4m53s
Test / Hakurei (race detector) (push) Successful in 5m48s
Test / Flake checks (push) Successful in 1m43s
All checks were successful
Test / Create distribution (push) Successful in 43s
Test / Sandbox (push) Successful in 2m34s
Test / Hakurei (push) Successful in 3m37s
Test / ShareFS (push) Successful in 3m42s
Test / Hpkg (push) Successful in 4m18s
Test / Sandbox (race detector) (push) Successful in 4m53s
Test / Hakurei (race detector) (push) Successful in 5m48s
Test / Flake checks (push) Successful in 1m43s
This avoids missing the cleanup when cure returns an error. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user