diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 22:10:44 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-15 22:10:44 +0200 |
| commit | 6b38d302daa54140e4e26ad903297a1bba0cbd41 (patch) | |
| tree | 2f32472e751de41f8fbbbeed739f0e66a4cb5211 /internal/engine | |
| parent | bbc9b103acac96b83b150b81f2effe1b65c3f8a2 (diff) | |
| download | krino-6b38d302daa54140e4e26ad903297a1bba0cbd41.tar.gz krino-6b38d302daa54140e4e26ad903297a1bba0cbd41.zip | |
a failed duplicate lookup is unknown, like unreadable content
Diffstat (limited to 'internal/engine')
| -rw-r--r-- | internal/engine/exclude_test.go | 29 | ||||
| -rw-r--r-- | internal/engine/match.go | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/internal/engine/exclude_test.go b/internal/engine/exclude_test.go index 6381a04..7069623 100644 --- a/internal/engine/exclude_test.go +++ b/internal/engine/exclude_test.go @@ -547,3 +547,32 @@ func TestNotMatchedAfterAnUnknownRuleDoesNotAct(t *testing.T) { } } } + +// TestDuplicateExcludeFailsClosed: an exclude whose duplicate lookup fails +// holds, marked as such (plan 12). +func TestDuplicateExcludeFailsClosed(t *testing.T) { + if os.Getuid() == 0 { + t.Skip("root reads a chmod 000 file") + } + h, dl := excludeTree(t, map[string]string{"a.txt": "same size", "b.txt": "same size"}) + os.Chmod(filepath.Join(dl, "a.txt"), 0) + t.Cleanup(func() { os.Chmod(filepath.Join(dl, "a.txt"), 0o644) }) + main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": ` +(path "~/dl") +(exclude (duplicate)) +(rule "all" (move "Out")) +`}) + e, errs := Load(main) + if len(errs) > 0 { + t.Fatal(errs) + } + r, err := e.Match(context.Background(), e.Dirs[0]) + if err != nil { + t.Fatal(err) + } + for _, fm := range r.Matched { + if fm.File.Rel == "a.txt" && fm.Excluded != "(exclude (duplicate)) (duplicate check failed)" { + t.Errorf("a.txt: Excluded %q, rules %d; want set aside as duplicate check failed", fm.Excluded, len(fm.Rules)) + } + } +} diff --git a/internal/engine/match.go b/internal/engine/match.go index 2ef3ae1..f6e1706 100644 --- a/internal/engine/match.go +++ b/internal/engine/match.go @@ -367,7 +367,7 @@ func excludedBy(x *Exclude, res cond.Result) string { case res.Match: return x.Text case res.Unreadable: - return x.Text + " (content unreadable)" + return x.Text + " (" + res.Undecided + ")" } return "" } |
