diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-11-23 19:07:39 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-11-23 19:07:39 +0900 |
| commit | d58c561a067bf55449d82e3297062f2b80547089 (patch) | |
| tree | 570f64e365c510e61a3365a5074d3b1448a3d955 /pkg/pkg.go | |
| parent | ca6d417715000d25439e7c46403267b6e3723036 (diff) | |
pkg: notify nature of exit
This change breaks API. It is seen as an acceptable tradeoff here since
this field has no known users other than cmd/mbf, and maintaining
compatibility is very ugly in this case.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'pkg/pkg.go')
| -rw-r--r-- | pkg/pkg.go | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -1785,10 +1785,19 @@ func (e InputError) Unwrap() []error { return errs } +const ( + // NExit indicates a cure implementation being exited. + NExit = iota + // NEnter indicates a cure implementation being entered. + NEnter + // NFault is sent in place of [NExit] for a faulting implementation. + NFault +) + // enterCure must be called before entering an [Artifact] implementation. func (c *Cache) enterCure(a Artifact, curesExempt bool) error { if c.attr.Notify != nil { - c.attr.Notify <- true + c.attr.Notify <- NEnter } if a.IsExclusive() { @@ -1812,9 +1821,13 @@ func (c *Cache) enterCure(a Artifact, curesExempt bool) error { } // exitCure must be called after exiting an [Artifact] implementation. -func (c *Cache) exitCure(a Artifact, curesExempt bool) { +func (c *Cache) exitCure(a Artifact, curesExempt, ok bool) { if c.attr.Notify != nil { - c.attr.Notify <- false + if ok { + c.attr.Notify <- NExit + } else { + c.attr.Notify <- NFault + } } if a.IsExclusive() { @@ -2282,7 +2295,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( err = closeErr } } - c.exitCure(a, curesExempt) + c.exitCure(a, curesExempt, err == nil) if err != nil { if c.msg.IsVerbose() { c.msg.Verbosef( @@ -2333,7 +2346,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( return } err = ca.Cure(&t) - c.exitCure(a, curesExempt) + c.exitCure(a, curesExempt, err == nil) if err != nil { if c.msg.IsVerbose() { c.msg.Verbosef( @@ -2505,7 +2518,7 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( return } err = ca.Cure(&f) - c.exitCure(a, curesExempt) + c.exitCure(a, curesExempt, err == nil) if !rebuild && err == nil { err = f.linkSubstitute(ids, substitutes) @@ -2749,7 +2762,7 @@ type CacheAttr struct { // Preferred loadavg target, when applicable. Load int // Optional cure entry and exit notification. - Notify chan<- bool + Notify chan<- int // Omit the [lockedfile] lock. skipLock bool |
