Resolve scan operands to their real paths (closes #144)
check / check (push) Canceled after 0s

scan now resolves every operand with its symlinks followed before the
walk, and uses that real path for pruning, walking, records and
warnings. A symlink operand is scanned at its target instead of
skipped. An operand given through a symlinked directory below another
operand is walked on its own instead of dropped with its records
deleted. A dangling symlink operand is a fatal error, like a missing
path. The walk itself still follows no symlink.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-06 17:55:13 +00:00
1 parent f52bbe5d95
commit ab18955bf0
5 files changed
+250 -123

No files matched your search

+8 -7
View File
@@ -2310,15 +2310,16 @@ func TestUnderRoot(t *testing.T) {
}
// TestRunScanPassesOverDatabase scans a tree that holds the scan's own
// database, reached directly and through a symlinked directory. The
// walk passes over the database file, its -wal and -shm files and its
// .lock file with no line and no count, and the record an earlier scan
// left for the .lock file is deleted. A rescan of the unchanged tree
// database, given directly and through a symlinked directory, which
// the scan resolves to the same real path. The walk passes over the
// database file, its -wal and -shm files and its .lock file with no
// line and no count, and the record an earlier scan left for the .lock
// file is deleted. A rescan of the unchanged tree
// updates nothing, and report lists none of the database's files.
func TestRunScanPassesOverDatabase(t *testing.T) {
for _, viaSymlink := range []bool{false, true} {
t.Run(fmt.Sprintf("via symlink %v", viaSymlink), func(t *testing.T) {
base := t.TempDir()
base := realTempDir(t)
tree := filepath.Join(base, "real", "tree")
operand := tree
@@ -2346,7 +2347,7 @@ func TestRunScanPassesOverDatabase(t *testing.T) {
}
err = applyChanges(t.Context(), db, []scanRec{
{path: filepath.Join(operand, "db.sqlite.lock")},
{path: filepath.Join(tree, "db.sqlite.lock")},
}, nil, nil)
if err != nil {
t.Fatal(err)
@@ -2363,7 +2364,7 @@ func TestRunScanPassesOverDatabase(t *testing.T) {
report := runStdout(t, cmdReport)
if strings.Contains(report, "db.sqlite") ||
!strings.Contains(report, filepath.Join(operand, "empty2")) {
!strings.Contains(report, filepath.Join(tree, "empty2")) {
t.Errorf("report = %q, want the empty files and none of "+
"the database's files", report)
}