internal/pkg: cure entry/exit notification
Test / Create distribution (push) Successful in 55s
Test / Sandbox (push) Successful in 2m55s
Test / Hakurei (push) Successful in 4m49s
Test / Sandbox (race detector) (push) Successful in 6m7s
Test / Hakurei (race detector) (push) Successful in 7m42s
Test / ShareFS (push) Successful in 8m10s
Test / Flake checks (push) Successful in 1m39s

This enables cure status display without inspecting internal state.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
cat
2026-07-31 13:58:32 +09:00
parent 4e41b9bc99
commit 280a736ce3
+14
View File
@@ -1826,6 +1826,10 @@ func (e *DependencyCureError) Error() string {
// enterCure must be called before entering an [Artifact] implementation. // enterCure must be called before entering an [Artifact] implementation.
func (c *Cache) enterCure(a Artifact, curesExempt bool) error { func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
if c.attr.Notify != nil {
c.attr.Notify <- true
}
if a.IsExclusive() { if a.IsExclusive() {
c.exclMu.Lock() c.exclMu.Lock()
} }
@@ -1848,6 +1852,10 @@ func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
// exitCure must be called after exiting an [Artifact] implementation. // exitCure must be called after exiting an [Artifact] implementation.
func (c *Cache) exitCure(a Artifact, curesExempt bool) { func (c *Cache) exitCure(a Artifact, curesExempt bool) {
if c.attr.Notify != nil {
c.attr.Notify <- false
}
if a.IsExclusive() { if a.IsExclusive() {
c.exclMu.Unlock() c.exclMu.Unlock()
} }
@@ -2741,6 +2749,10 @@ func (c *Cache) Close() {
c.wg.Wait() c.wg.Wait()
close(c.cures) close(c.cures)
c.unlock() c.unlock()
if c.attr.Notify != nil {
close(c.attr.Notify)
}
} }
// UnsupportedVariantError describes an on-disk cache with an extension variant // UnsupportedVariantError describes an on-disk cache with an extension variant
@@ -2768,6 +2780,8 @@ type CacheAttr struct {
Jobs int Jobs int
// Preferred loadavg target, when applicable. // Preferred loadavg target, when applicable.
Load int Load int
// Optional cure entry and exit notification.
Notify chan<- bool
// Omit the [lockedfile] lock. // Omit the [lockedfile] lock.
skipLock bool skipLock bool