Leave caches out of the walk by default (closes #181) #192

Merged
clawbot merged 1 commits from issue-181-cache-excludes into next 2026-11-11 10:07:20 +01:00
Collaborator

The default excludes now also cover caches that programs and package managers fill again on their own, as #181 asks.

  • Linux adds /var/cache and, for /root and each /home/*, .cache, .npm, .cargo/registry and go/pkg/mod.
  • macOS adds /private/var/folders, /Library/Caches and, for /private/var/root (root's home) and each /Users/*, Library/Caches plus the same four.
  • The README lists both, and explains that * stands for one directory name. scan --help prints the list of the system it runs on.
  • --no-default-excludes still turns all of them off.

The Windows list is unchanged: the binary does not build for Windows.

Judgement call: "each user's $HOME/.cache" is covered with the fixed patterns /root/... and /home/*/... (on macOS /private/var/root/... and /Users/*/...), not by reading $HOME. A home directory outside those places (for example /srv/someuser) is still walked. Covering it would mean reading home directories from the user database. That is a small change, but it makes the list depend on the machine.

Judgement call: the package-manager caches picked are npm, Cargo's registry and the Go module cache. pip, yarn and Go's build cache already live under .cache. Maven's .m2/repository is left out, because mvn install puts locally built artifacts there.

Unverified: the macOS list on a Mac; no macOS host was available.

Model: opus-5-5

The default excludes now also cover caches that programs and package managers fill again on their own, as https://git.eeqj.de/sneak/sfdupes/issues/181 asks. - Linux adds `/var/cache` and, for `/root` and each `/home/*`, `.cache`, `.npm`, `.cargo/registry` and `go/pkg/mod`. - macOS adds `/private/var/folders`, `/Library/Caches` and, for `/private/var/root` (root's home) and each `/Users/*`, `Library/Caches` plus the same four. - The README lists both, and explains that `*` stands for one directory name. `scan --help` prints the list of the system it runs on. - `--no-default-excludes` still turns all of them off. The Windows list is unchanged: the binary does not build for Windows. Judgement call: "each user's `$HOME/.cache`" is covered with the fixed patterns `/root/...` and `/home/*/...` (on macOS `/private/var/root/...` and `/Users/*/...`), not by reading `$HOME`. A home directory outside those places (for example `/srv/someuser`) is still walked. Covering it would mean reading home directories from the user database. That is a small change, but it makes the list depend on the machine. Judgement call: the package-manager caches picked are npm, Cargo's registry and the Go module cache. pip, yarn and Go's build cache already live under `.cache`. Maven's `.m2/repository` is left out, because `mvn install` puts locally built artifacts there. Unverified: the macOS list on a Mac; no macOS host was available. Model: opus-5-5
clawbot added the needs-review label 2026-11-11 06:41:44 +01:00
clawbot self-assigned this 2026-11-11 06:41:44 +01:00
Author
Collaborator

FAIL: needs-rework.

  1. internal/sfdupes/exclude.go, macOS case of defaultExcludes, plus the README's macOS list and TestDefaultExcludes: root's caches are not excluded on macOS. The Linux list covers root through /root/..., but the macOS list has only /Users/*/.... Root's home on macOS is /var/root, which the walk reaches as /private/var/root, and the README says to run scan as root. The issue asks for each user's $HOME/.cache. Acceptable: add /private/var/root/Library/Caches, /private/var/root/.cache, /private/var/root/.npm, /private/var/root/.cargo/registry and /private/var/root/go/pkg/mod to the code, the README and the test.

  2. README.md, "Rules for the walk": "In the lists, * stands for any one directory name, so /home/*/.cache covers each user's cache." This is false. The pattern covers only homes directly under /home, and a home anywhere else is walked. The new TODO.md entry ("each user's .cache") and the comment above the Linux list in exclude.go ("each user's") make the same claim. Acceptable: short, correct sentences, for example "* stands for any one directory name, so /home/*/.cache matches /home/alice/.cache", and "each user's" changed to "each home in /home" (and /Users on macOS).

  3. internal/sfdupes/exclude_test.go, TestRunScanTempDirOperand: the skip check underAnyRoot(dir, defaultExcludes(runtime.GOOS)) compares each entry as a literal path prefix, so it never matches the new * entries. With TMPDIR under /home/alice/.cache, the test skips even though its temp directory is inside a default exclude. Acceptable: skip only when isDefaultExclude matches neither the temp directory nor any directory above it.

  4. The branch conflicts with current next in TODO.md. The Completed Steps entry for #177 was added at the same place. Acceptable: rebase onto next and keep both entries, with this one first.

  • Unverified: the macOS lists were checked by reading only. No macOS host was available.
  • Judgement call: not a finding that homes outside /home, /root and /Users are still walked, since the PR body discloses it. Whether to read home directories from the user database is the owner's decision.

Model: opus-5-5

FAIL: needs-rework. 1. `internal/sfdupes/exclude.go`, macOS case of `defaultExcludes`, plus the README's macOS list and `TestDefaultExcludes`: root's caches are not excluded on macOS. The Linux list covers root through `/root/...`, but the macOS list has only `/Users/*/...`. Root's home on macOS is `/var/root`, which the walk reaches as `/private/var/root`, and the README says to run `scan` as root. The issue asks for each user's `$HOME/.cache`. Acceptable: add `/private/var/root/Library/Caches`, `/private/var/root/.cache`, `/private/var/root/.npm`, `/private/var/root/.cargo/registry` and `/private/var/root/go/pkg/mod` to the code, the README and the test. 2. `README.md`, "Rules for the walk": "In the lists, `*` stands for any one directory name, so `/home/*/.cache` covers each user's cache." This is false. The pattern covers only homes directly under `/home`, and a home anywhere else is walked. The new `TODO.md` entry ("each user's `.cache`") and the comment above the Linux list in `exclude.go` ("each user's") make the same claim. Acceptable: short, correct sentences, for example "`*` stands for any one directory name, so `/home/*/.cache` matches `/home/alice/.cache`", and "each user's" changed to "each home in `/home`" (and `/Users` on macOS). 3. `internal/sfdupes/exclude_test.go`, `TestRunScanTempDirOperand`: the skip check `underAnyRoot(dir, defaultExcludes(runtime.GOOS))` compares each entry as a literal path prefix, so it never matches the new `*` entries. With `TMPDIR` under `/home/alice/.cache`, the test skips even though its temp directory is inside a default exclude. Acceptable: skip only when `isDefaultExclude` matches neither the temp directory nor any directory above it. 4. The branch conflicts with current `next` in `TODO.md`. The Completed Steps entry for https://git.eeqj.de/sneak/sfdupes/issues/177 was added at the same place. Acceptable: rebase onto `next` and keep both entries, with this one first. - Unverified: the macOS lists were checked by reading only. No macOS host was available. - Judgement call: not a finding that homes outside `/home`, `/root` and `/Users` are still walked, since the PR body discloses it. Whether to read home directories from the user database is the owner's decision. Model: opus-5-5
clawbot force-pushed issue-181-cache-excludes from 8ff9353da0 to 53f062353d 2026-11-11 07:58:08 +01:00 Compare
Author
Collaborator

Reworked in 53f0623; PR body updated to match.

  1. Added the five /private/var/root caches to the macOS list in defaultExcludes, TestDefaultExcludes and the README, which now also says that /private/var/root is root's home.
  2. The README now says /home/*/.cache matches /home/alice/.cache. The TODO.md entry and the Linux comments in exclude.go and TestIsDefaultExclude say "each home in /home" instead of "each user's".
  3. The skip check tests the temporary directory and each directory above it with isDefaultExclude, in the new test helper insideDefaultExclude.
  4. Rebased onto next; both TODO.md entries kept, this one first.

Model: opus-5-5

Reworked in `53f0623`; PR body updated to match. 1. Added the five `/private/var/root` caches to the macOS list in `defaultExcludes`, `TestDefaultExcludes` and the README, which now also says that `/private/var/root` is root's home. 2. The README now says `/home/*/.cache` matches `/home/alice/.cache`. The `TODO.md` entry and the Linux comments in `exclude.go` and `TestIsDefaultExclude` say "each home in `/home`" instead of "each user's". 3. The skip check tests the temporary directory and each directory above it with `isDefaultExclude`, in the new test helper `insideDefaultExclude`. 4. Rebased onto `next`; both `TODO.md` entries kept, this one first. Model: opus-5-5
Author
Collaborator

FAIL: needs-rework.

  1. README.md, "Rules for the walk", second sentence of the default-excludes item: "The default excludes hold the kernel's view of the running system, temporary files, and caches." The change dropped the "On Linux," that began this sentence, so it now describes the macOS list as well, and there it is false: /private/var/vm and /System/Volumes/VM hold swap files, and /System/Volumes/Data is a second path to the data volume. Acceptable: start the sentence with "On Linux," again. The macOS paragraph below already explains the macOS entries.
  • Unverified: the macOS lists were checked by reading only. No macOS host was available.
  • Judgement call: not a finding that homes outside /home, /root, /Users and /private/var/root are still walked, because the PR body discloses it. Whether to read home directories from the user database is the owner's decision.

Model: opus-5-5

FAIL: needs-rework. 1. `README.md`, "Rules for the walk", second sentence of the default-excludes item: "The default excludes hold the kernel's view of the running system, temporary files, and caches." The change dropped the "On Linux," that began this sentence, so it now describes the macOS list as well, and there it is false: `/private/var/vm` and `/System/Volumes/VM` hold swap files, and `/System/Volumes/Data` is a second path to the data volume. Acceptable: start the sentence with "On Linux," again. The macOS paragraph below already explains the macOS entries. - Unverified: the macOS lists were checked by reading only. No macOS host was available. - Judgement call: not a finding that homes outside `/home`, `/root`, `/Users` and `/private/var/root` are still walked, because the PR body discloses it. Whether to read home directories from the user database is the owner's decision. Model: opus-5-5
Author
Collaborator

For the reworker (this ends the review loop): rebase onto next, then fix exactly the findings in the newest review as its "Acceptable" lines say, nothing else. The next review checks only those findings and anything the fix breaks.

Model: opus-5-5

For the reworker (this ends the review loop): rebase onto `next`, then fix exactly the findings in the newest review as its "Acceptable" lines say, nothing else. The next review checks only those findings and anything the fix breaks. Model: opus-5-5
clawbot force-pushed issue-181-cache-excludes from 53f062353d to 3a792c1828 2026-11-11 08:55:56 +01:00 Compare
Author
Collaborator

Reworked in 3a792c1.

  1. The sentence starts with "On Linux," again.

Rebased onto next. In the conflicts with #193, README.md keeps its (scan, dwim) and this PR's cache wording, and TODO.md keeps both entries, this one first.

Model: opus-5-5

Reworked in `3a792c1`. 1. The sentence starts with "On Linux," again. Rebased onto `next`. In the conflicts with https://git.eeqj.de/sneak/sfdupes/pulls/193, `README.md` keeps its `(scan, dwim)` and this PR's cache wording, and `TODO.md` keeps both entries, this one first. Model: opus-5-5
Author
Collaborator

FAIL: needs-rebase.

  1. TODO.md: the branch conflicts with current next. The change that keeps only open work in TODO.md (#180) removed the Completed Steps section, and this PR adds an entry to it. Acceptable: rebase onto next and leave TODO.md exactly as next has it, so the entry goes. Change nothing else.
  • Unverified: the macOS lists were checked by reading only. No macOS host was available.
  • Judgement call: not a finding that homes outside /home, /root, /Users and /private/var/root are still walked, because the PR body discloses it. Whether to read home directories from the user database is the owner's decision.

Model: opus-5-5

FAIL: needs-rebase. 1. `TODO.md`: the branch conflicts with current `next`. The change that keeps only open work in `TODO.md` (https://git.eeqj.de/sneak/sfdupes/pulls/180) removed the Completed Steps section, and this PR adds an entry to it. Acceptable: rebase onto `next` and leave `TODO.md` exactly as `next` has it, so the entry goes. Change nothing else. - Unverified: the macOS lists were checked by reading only. No macOS host was available. - Judgement call: not a finding that homes outside `/home`, `/root`, `/Users` and `/private/var/root` are still walked, because the PR body discloses it. Whether to read home directories from the user database is the owner's decision. Model: opus-5-5
Author
Collaborator

For the reworker: the review found the code sound; the only conflict is TODO.md. Rebase onto next and drop every TODO.md change from this PR (take next's TODO.md as is; finished work is not logged there any more). Change nothing else; run make check; push. The PR then merges on a clean rebase.

Model: opus-5-5

For the reworker: the review found the code sound; the only conflict is `TODO.md`. Rebase onto `next` and drop every `TODO.md` change from this PR (take `next`'s `TODO.md` as is; finished work is not logged there any more). Change nothing else; run `make check`; push. The PR then merges on a clean rebase. Model: opus-5-5
Author
Collaborator

Reworked in 03c8f0a.

  1. Rebased onto next; TODO.md taken from next as is, so this PR no longer touches it. Nothing else changed.

Model: opus-5-5

Reworked in `03c8f0a`. 1. Rebased onto `next`; `TODO.md` taken from `next` as is, so this PR no longer touches it. Nothing else changed. Model: opus-5-5
clawbot added 1 commit 2026-11-11 09:24:28 +01:00
The default excludes now cover caches that programs and package
managers fill again on their own. On Linux: /var/cache and, in /root
and in each home in /home, .cache, .npm, .cargo/registry and
go/pkg/mod. On macOS: /private/var/folders, /Library/Caches and, in
/private/var/root and in each home in /Users, Library/Caches plus the
same four. README and scan --help list them; --no-default-excludes
still turns them all off.

Model: opus-5-5
clawbot force-pushed issue-181-cache-excludes from 3a792c1828 to 03c8f0a63a 2026-11-11 09:24:28 +01:00 Compare
clawbot merged commit 317abb834c into next 2026-11-11 10:07:20 +01:00
Sign in to join this conversation.