Commit Graph
1 Commits
Author SHA1 Message Date
yetone d5f6159109 usage: a test that a failed stat keeps the log's last read (f2039c13f)
f2039c13f kept the usage ledger's last good read when the log's stat
failed but for absence (@simonzyzy on X), and shipped with no test.
TestUnreadableLogKeepsItsLastRead takes search permission off the log's
folder, so the stat fails with EACCES, and checks that the last read
stands. It also checks that a log removed for real drops it.

Run: on mote, the new test -race -count=3 ok, and ./internal/usage ok
(37.7s), go vet ok, gofmt clean. On Linux (wsl-run, magpie-desktop),
-v shows the test run and pass, not skipped.
Red on the old code: with f2039c13f^'s log_index.go, it fails with
"a failed stat replaced the last read" (an empty snapshot, info nil).
Not tried: Windows. The test is !windows because its stat goes through
CreateFile there, and folder permissions don't fail it the same way.
2026-11-11 09:32:03 +08:00