freshen recorded a changed or new file's size from the scan and its hash from a later read. A file that grew or shrank between the two got an entry whose size came from one version of the file and whose hash from another, and check then failed that file with nothing saying why. processEntry now compares the bytes it read with the size the scan recorded and fails on a difference, naming the file, as gen already does in Builder.AddFile. freshen stops before writing, so it exits 1 and the manifest stays as it was.
The message reads: size mismatch for "log.txt": 3 bytes when scanned but 5 bytes when read; the file changed while freshen ran.
Worth knowing:
Only the size is compared. A file rewritten to the same size between the scan and the hash still goes unnoticed; the issue does not ask for more.
The CLI test wraps the filesystem so the file grows when freshen opens it to hash. During the scan the file is only stat'd, so that open is the first one after the scan.
Judgement call: the error wraps the errSizeMismatch already defined in internal/cli/fetch.go for downloads, rather than a new one; its comment now covers both uses.
Model: opus-5-5
Fixes https://git.eeqj.de/sneak/mfer/issues/207.
`freshen` recorded a changed or new file's size from the scan and its hash from a later read. A file that grew or shrank between the two got an entry whose size came from one version of the file and whose hash from another, and `check` then failed that file with nothing saying why. `processEntry` now compares the bytes it read with the size the scan recorded and fails on a difference, naming the file, as `gen` already does in `Builder.AddFile`. `freshen` stops before writing, so it exits 1 and the manifest stays as it was.
The message reads: `size mismatch for "log.txt": 3 bytes when scanned but 5 bytes when read; the file changed while freshen ran`.
Worth knowing:
- Only the size is compared. A file rewritten to the same size between the scan and the hash still goes unnoticed; the issue does not ask for more.
- The CLI test wraps the filesystem so the file grows when `freshen` opens it to hash. During the scan the file is only stat'd, so that open is the first one after the scan.
Judgement call: the error wraps the `errSizeMismatch` already defined in `internal/cli/fetch.go` for downloads, rather than a new one; its comment now covers both uses.
Model: opus-5-5
TestFreshenSizeChangedMessage in internal/cli/errmsg_test.go and TestFreshenFileChangedSinceScan in internal/cli/freshen_test.go both cover only a file that grew after the scan. Nothing tests a file that shrank, which the issue and the new code comment in processEntry both name, so a check that refused only growth would still pass the suite. Acceptable: a case where the scan recorded more bytes than the file holds when it is hashed, expecting the same refusal naming the file; a second case in the processEntry test is enough.
Model: opus-5-5
Review failed, one finding.
1. `TestFreshenSizeChangedMessage` in `internal/cli/errmsg_test.go` and `TestFreshenFileChangedSinceScan` in `internal/cli/freshen_test.go` both cover only a file that grew after the scan. Nothing tests a file that shrank, which the issue and the new code comment in `processEntry` both name, so a check that refused only growth would still pass the suite. Acceptable: a case where the scan recorded more bytes than the file holds when it is hashed, expecting the same refusal naming the file; a second case in the `processEntry` test is enough.
Model: opus-5-5
freshen took a changed or new file's size from the scan and its hash
from a later read, without comparing the bytes read with that size. A
file that grew or shrank in between got an entry no content can match,
so check failed it with nothing saying why. processEntry now fails with
a size mismatch naming the file, as gen does, so freshen exits 1 and
leaves the manifest as it was.
Judgement call: the error wraps the package's existing errSizeMismatch
from fetch; its comment now covers both uses.
Model: opus-5-5
Added a case where the scan recorded more bytes than the file holds when hashed (TestFreshenSizeChangedMessage now has grown and shrunk subtests); it expects the same refusal naming the file.
Model: opus-5-5
Added a case where the scan recorded more bytes than the file holds when hashed (`TestFreshenSizeChangedMessage` now has `grown` and `shrunk` subtests); it expects the same refusal naming the file.
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.
Fixes #207.
freshenrecorded a changed or new file's size from the scan and its hash from a later read. A file that grew or shrank between the two got an entry whose size came from one version of the file and whose hash from another, andcheckthen failed that file with nothing saying why.processEntrynow compares the bytes it read with the size the scan recorded and fails on a difference, naming the file, asgenalready does inBuilder.AddFile.freshenstops before writing, so it exits 1 and the manifest stays as it was.The message reads:
size mismatch for "log.txt": 3 bytes when scanned but 5 bytes when read; the file changed while freshen ran.Worth knowing:
freshenopens it to hash. During the scan the file is only stat'd, so that open is the first one after the scan.Judgement call: the error wraps the
errSizeMismatchalready defined ininternal/cli/fetch.gofor downloads, rather than a new one; its comment now covers both uses.Model: opus-5-5
Review failed, one finding.
TestFreshenSizeChangedMessageininternal/cli/errmsg_test.goandTestFreshenFileChangedSinceScanininternal/cli/freshen_test.goboth cover only a file that grew after the scan. Nothing tests a file that shrank, which the issue and the new code comment inprocessEntryboth name, so a check that refused only growth would still pass the suite. Acceptable: a case where the scan recorded more bytes than the file holds when it is hashed, expecting the same refusal naming the file; a second case in theprocessEntrytest is enough.Model: opus-5-5
953fca87f9to813914ec63Added a case where the scan recorded more bytes than the file holds when hashed (
TestFreshenSizeChangedMessagenow hasgrownandshrunksubtests); it expects the same refusal naming the file.Model: opus-5-5
Review passed.
Model: opus-5-5