Compare commits

..
1 Commits
Author SHA1 Message Date
clawbot 03a1db8eb6 Leave removed copies out of report and trees (closes #173)
check / check (push) Canceled after 0s
A deleted duplicate stayed in both reports until a scan covered it, and
a missing scan operand is a fatal error. report now runs lstat on each
path of a possible duplicate group and drops paths that are gone; trees
does the same for the directory at the top of each copy, never the
files inside. A group left with one copy is not reported. Only "does not
exist" and "not a directory" count as gone, so a permission error keeps
the copy for an unprivileged user. README says a stale report is fixed
by scanning again.

Model: opus-5-5
2026-11-11 03:01:18 +00:00
2 changed files with 6 additions and 10 deletions

No files matched your search

+4 -4
View File
@@ -491,9 +491,9 @@ func TestReadReportChecksOnlyPossibleDuplicates(t *testing.T) {
a, u, e := testHash("a"), testHash("u"), sha256.Sum256(nil)
recs := []scanRec{
{size: 9, head: a, tail: a, content: a, path: "/x/1"},
{size: 9, head: a, tail: a, content: a, path: "/x/2"},
{size: 9, head: a, tail: a, content: a, path: "/x/3"},
{size: 9, head: a, tail: a, content: a, path: "/copy/1"},
{size: 9, head: a, tail: a, content: a, path: "/copy/2"},
{size: 9, head: a, tail: a, content: a, path: "/copy/3"},
{size: 9, head: u, tail: u, content: u, path: "/lonely"},
{size: 0, head: e, tail: e, content: e, path: "/empty1"},
{size: 0, head: e, tail: e, content: e, path: "/empty2"},
@@ -521,7 +521,7 @@ func TestReadReportChecksOnlyPossibleDuplicates(t *testing.T) {
slices.Sort(checked)
want := []string{"/x/1", "/x/2", "/x/3"}
want := []string{"/copy/1", "/copy/2", "/copy/3"}
if !slices.Equal(checked, want) {
t.Errorf("paths checked on disk = %q, want %q", checked, want)
}
+2 -6
View File
@@ -503,20 +503,16 @@ func TestCollectTreeGroupsDifferingParents(t *testing.T) {
// TestCollectTreeGroupsChecksOnlyReportedCopies checks that trees asks
// whether a directory is on disk only for the members of the groups it
// returns. It never asks about /a/proj/sub, which lies inside a copy
// and whose group the group of /a/proj implies, nor about /a/empty,
// which holds 0 bytes.
// and whose group the group of /a/proj implies.
func TestCollectTreeGroupsChecksOnlyReportedCopies(t *testing.T) {
t.Parallel()
f, g, u, e := testHash("f"), testHash("g"), testHash("u"),
sha256.Sum256(nil)
f, g, u := testHash("f"), testHash("g"), testHash("u")
recs := []scanRec{
{size: 10, head: f, tail: f, content: f, path: "/a/proj/f"},
{size: 20, head: g, tail: g, content: g, path: "/a/proj/sub/g"},
{size: 0, head: e, tail: e, content: e, path: "/a/empty/.gitkeep"},
{size: 10, head: f, tail: f, content: f, path: "/b/proj/f"},
{size: 20, head: g, tail: g, content: g, path: "/b/proj/sub/g"},
{size: 0, head: e, tail: e, content: e, path: "/b/empty/.gitkeep"},
// /a lacks this file, so /a and /b are no copies of each other.
{size: 30, head: u, tail: u, content: u, path: "/b/lonely"},
}