Name the database each command uses on stderr (closes #111)
check / check (push) Canceled after 0s

scan, report and trees now print one line on stderr before anything
else, naming the database and whether its path is the default or comes
from SFDUPES_DATABASE; scan also says when the file is new. report and
trees print it before opening the database, so a missing-database error
follows it. A relative path gets the working directory put in front of
it, with its symlinks resolved as the kernel reports it, and is not
cleaned: a ".." after a symlink names another file than the cleaned
path does. README "Database" lists when scan writes each file.

Unverified: the line on a terminal has no test of its own.

Model: opus-5-5
This commit was merged in pull request #118.
This commit is contained in:
2026-10-16 15:28:02 +02:00
parent 198cefa152
commit 264817c413
9 changed files with 412 additions and 36 deletions
+6 -4
View File
@@ -344,9 +344,10 @@ func storedPaths(t *testing.T, path string) []string {
// TestRunScanInterrupted calls the scan entrypoint with a context that
// is already cancelled, as when a signal arrives at once. It must return
// errInterrupted promptly with its one line on stderr and nothing on
// stdout, leave the database valid and as it was, and leave nothing in
// the way of the next scan, which must bring the database up to date.
// errInterrupted promptly, with its line on stderr after the one naming
// the database and nothing on stdout, leave the database valid and as
// it was, and leave nothing in the way of the next scan, which must
// bring the database up to date.
func TestRunScanInterrupted(t *testing.T) {
path := testDBPath(t)
t.Setenv(databaseEnv, path)
@@ -389,7 +390,8 @@ func TestRunScanInterrupted(t *testing.T) {
err, errInterrupted)
}
want := "scan: interrupted after 0 files\n"
want := "scan: database " + path + " (from " + databaseEnv + ")\n" +
"scan: interrupted after 0 files\n"
if got := stderr()[shown:]; got != want {
t.Errorf("stderr = %q, want %q", got, want)
}