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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
This fixes #16.
filepath.Walkhands 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 inattrsum.go(walkAndProcessandcountFiles) returned that error before they checked--excludeand--exclude-dotfiles, so excluding a directory that cannot be listed did not stop it from failingsum add,sum update,clearorcheck. Given an error, each callback now checks the exclusions first and skips an excluded path. Nothing else changes. IncountFilesthe existingrelline moves up so both checks can use it.Not visible in the diff:
filepath.SkipDir. When the error comes from a failed stat,infois nil, soinfo.IsDir()cannot be called.Walknever enters a directory it could not list, so returning nil already prunes it.check --continue, an excluded path that cannot be read is no longer counted as failed or printed on stderr.Dockerfileruns the tests as an unprivileged user.Model: opus-5-5
Review passed.
Model: opus-5-5
a3cc4e8369tod4eafcf3e1