release / go (push) Successful in 2m17s
release / web (push) Successful in 1m29s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m28s
release / android (push) Successful in 4m25s
release / Build signed APK (push) Successful in 5m8s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 15s
release / Verify release artifacts (tag releases only) (push) Skipped
The resolver checked for a running scan once, at the start of a pass. At boot that check could run before the startup scan recorded its run, and a scan that began mid-pass was never seen, so the pass removed copies the scan had listed (23 "no such file" errors on dev, 2026-11-28). A gate now keeps the two apart for their whole length: a full scan and each watcher batch hold it, a scan that meets a pass waits for it (up to 30 minutes, then gives up with a named error), and a pass that meets a scan is put off and tried again a minute later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
1.9 KiB
Go
61 lines
1.9 KiB
Go
package library
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
// filesGate keeps reading the library's files apart from removing them. A
|
|
// full scan holds it for its whole length and the watcher for each batch;
|
|
// a duplicate-resolver pass, which removes the copies it merges, runs only
|
|
// while no one else holds it. Without it, a file a scan has listed could be
|
|
// removed under the scan, and a file read just before its removal would put
|
|
// back a track whose file is gone.
|
|
//
|
|
// A scan that starts during a resolver pass waits for the pass to finish,
|
|
// up to filesWaitLimit. A resolver pass that finds the gate taken is put off
|
|
// and tried again (DuplicateResolveWorker).
|
|
var filesGate = make(gate, 1)
|
|
|
|
// filesWaitLimit is how long a scan waits for a resolver pass to let go of
|
|
// the files. A pass is capped at resolveMergeCap merges and takes minutes;
|
|
// one still holding them after this long is stuck, and the scan gives up
|
|
// rather than wait forever.
|
|
const filesWaitLimit = 30 * time.Minute
|
|
|
|
// errFilesBusy is a scan giving up on a resolver pass that held the files
|
|
// past filesWaitLimit.
|
|
var errFilesBusy = errors.New("library files held by a duplicate-resolver pass past the wait limit")
|
|
|
|
// gate is a lock that a waiter can give up on.
|
|
type gate chan struct{}
|
|
|
|
// acquire takes the gate, or returns ctx's error when ctx ends first and
|
|
// errFilesBusy once limit has passed.
|
|
func (g gate) acquire(ctx context.Context, limit time.Duration) error {
|
|
t := time.NewTimer(limit)
|
|
defer t.Stop()
|
|
select {
|
|
case g <- struct{}{}:
|
|
return nil
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-t.C:
|
|
return errFilesBusy
|
|
}
|
|
}
|
|
|
|
// tryAcquire takes the gate if no one holds it, and reports whether it did.
|
|
func (g gate) tryAcquire() bool {
|
|
select {
|
|
case g <- struct{}{}:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
// release lets go of a gate acquire or tryAcquire took.
|
|
func (g gate) release() { <-g }
|