Skip excluded paths before looking at their errors (closes #16) #19

Merged
clawbot merged 1 commits from exclude-before-error into next 2026-10-06 07:44:02 +02:00
Collaborator

This fixes #16.

filepath.Walk hands its callback the error for a path it could not read, such as a directory it cannot list or an entry it cannot stat. Both callbacks in attrsum.go (walkAndProcess and countFiles) returned that error before they checked --exclude and --exclude-dotfiles, so excluding a directory that cannot be listed did not stop it from failing sum add, sum update, clear or check. Given an error, each callback now checks the exclusions first and skips an excluded path. Nothing else changes. In countFiles the existing rel line moves up so both checks can use it.

Not visible in the diff:

  • The skip returns nil, not filepath.SkipDir. When the error comes from a failed stat, info is nil, so info.IsDir() cannot be called. Walk never enters a directory it could not list, so returning nil already prunes it.
  • With check --continue, an excluded path that cannot be read is no longer counted as failed or printed on stderr.
  • The new test needs a non-root user. Root can list a mode 0000 directory, so as root the test also passes on the old code. The Dockerfile runs the tests as an unprivileged user.

Model: opus-5-5

This fixes https://git.eeqj.de/sneak/attrsum/issues/16. `filepath.Walk` hands its callback the error for a path it could not read, such as a directory it cannot list or an entry it cannot stat. Both callbacks in `attrsum.go` (`walkAndProcess` and `countFiles`) returned that error before they checked `--exclude` and `--exclude-dotfiles`, so excluding a directory that cannot be listed did not stop it from failing `sum add`, `sum update`, `clear` or `check`. Given an error, each callback now checks the exclusions first and skips an excluded path. Nothing else changes. In `countFiles` the existing `rel` line moves up so both checks can use it. Not visible in the diff: - The skip returns nil, not `filepath.SkipDir`. When the error comes from a failed stat, `info` is nil, so `info.IsDir()` cannot be called. `Walk` never enters a directory it could not list, so returning nil already prunes it. - With `check --continue`, an excluded path that cannot be read is no longer counted as failed or printed on stderr. - The new test needs a non-root user. Root can list a mode 0000 directory, so as root the test also passes on the old code. The `Dockerfile` runs the tests as an unprivileged user. Model: opus-5-5
clawbot added the needs-review label 2026-10-06 06:17:35 +02:00
clawbot self-assigned this 2026-10-06 06:17:35 +02:00
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-06 07:00:46 +02:00
clawbot added 1 commit 2026-10-06 07:36:38 +02:00
filepath.Walk hands its callback the error for a path it could not
read, such as a directory it cannot list. Both callbacks, in
walkAndProcess and countFiles, returned that error before they checked
the exclusions, so a directory that --exclude or --exclude-dotfiles
excluded still failed the run when it could not be listed. Given an
error, each callback now checks the exclusions first and skips an
excluded path. The new test excludes a directory that cannot be listed
and runs sum add and check over its parent.

Model: opus-5-5
clawbot force-pushed exclude-before-error from a3cc4e8369 to d4eafcf3e1 2026-10-06 07:36:38 +02:00 Compare
clawbot added needs-review and removed needs-rebase labels 2026-10-06 07:36:44 +02:00
clawbot merged commit c4b50e2b55 into next 2026-10-06 07:44:02 +02:00
clawbot deleted branch exclude-before-error 2026-10-06 07:44:03 +02:00
Sign in to join this conversation.