Handle SIGINT/SIGTERM gracefully during scan #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There is no signal handling anywhere in the repo —
os/signalis never imported.runScan(scan.go:53-78) installs no handler, the walk dispatcher and hash worker pools (scan.go:373,scan.go:590-613) have no cancellation path, andprogress.gonever finishes the bar or restores the terminal line.The headline use case is a multi-hour scan of ~10M files / ~150 TB, run from cron or interactively. An operator who interrupts at hour three kills the process mid-render: no final summary, no clean terminal, no controlled commit of the in-flight batch. Batched commits mean most work survives, but the shutdown is uncontrolled and undocumented.
Definition of done
scaninstallssignal.NotifyContextfor SIGINT and SIGTERM; the resultingctxis threaded as the first argument through the walk dispatcher, the hash pool and the database writes, per the Go styleguide.scan: interrupted after N filesline goes to stderr and the process exits 1. README §Error handling documents the interrupt behaviour and the exit code.make checkgreen.Depends on #4 (the database must actually close) and overlaps #6 (the pools must be cancellable).