Commit 2822f2d
committed
backup: PR810 r6 — codex r5 P2 (empty CHECKSUMS + missing-target classification)
Two codex P2 findings on r5 (commit 7a8e2f3):
1. (codex P2, checksums.go:256) VerifyChecksums returned nil on
a CHECKSUMS file with zero parsed rows (empty file, blank
lines only). Phase 0a dumps are non-empty by construction
(WriteChecksums lists every regular file), so a zero-row
CHECKSUMS is always a producer-side corruption signal, never
a benign shape. The verifier was hiding partial-write or
truncation failures behind a "no rows checked == OK" answer.
Fix: VerifyChecksums now counts verified rows and returns
ErrChecksumsEmpty when the count is zero. Blank lines still
skip silently (matching sha256sum -c's tolerance of trailing
newlines) but do not satisfy the at-least-one-row guard.
Test: TestVerifyChecksums_RejectsEmptyChecksumsFile covers
three corruption shapes (empty file, blank lines only,
trailing-newline only).
2. (codex P2, checksums.go:306) refuseSymlinkComponents returned
raw fs.ErrNotExist when a CHECKSUMS-listed file was missing
from disk. Callers branching on errors.Is(err,
ErrChecksumMismatch) missed this case — partial restores and
tamper-deletes produced an unclassified path error instead.
Fix: detect fs.ErrNotExist at the refuseSymlinkComponents
call site (and at sha256File's call site as belt-and-braces)
and promote to ErrChecksumMismatch. The design's contract
("Files referenced by CHECKSUMS but missing on disk surface
as the same error class so a partial-restore is obvious") is
now honored.
Test: TestVerifyChecksums_MissingTargetIsMismatch — writes
a CHECKSUMS row, deletes the listed file, asserts
ErrChecksumMismatch via errors.Is.
API shape: verifyOneChecksumLine returns (bool, error) so the
parent loop can count "real" verified rows separately from
blank-line skips. Internal helper; signature change does not
escape the package.
Caller audit:
- verifyOneChecksumLine is internal to checksums.go; the
signature change is contained.
- VerifyChecksums has no production callers yet (test-only).
The new ErrChecksumsEmpty and the promoted ErrChecksumMismatch
shapes are additive on the typed-sentinel surface; honest
CHECKSUMS still verify cleanly.
Self-review:
1. Data loss — none; both fixes catch silent-corruption signals.
2. Concurrency — none.
3. Performance — one int counter per file; sha256 streaming
unchanged.
4. Data consistency — empty-CHECKSUMS hole closed; missing-
target now classified.
5. Test coverage — two new tests; existing thirteen CHECKSUMS
tests still pass.1 parent 7a8e2f3 commit 2822f2d
2 files changed
Lines changed: 117 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
| 240 | + | |
| 241 | + | |
239 | 242 | | |
240 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
245 | 260 | | |
246 | 261 | | |
247 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
248 | 270 | | |
249 | 271 | | |
250 | 272 | | |
251 | 273 | | |
252 | 274 | | |
253 | 275 | | |
254 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
255 | 285 | | |
256 | | - | |
| 286 | + | |
257 | 287 | | |
258 | 288 | | |
259 | 289 | | |
260 | | - | |
| 290 | + | |
261 | 291 | | |
262 | 292 | | |
263 | 293 | | |
264 | | - | |
| 294 | + | |
265 | 295 | | |
266 | 296 | | |
267 | 297 | | |
268 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
269 | 310 | | |
270 | 311 | | |
271 | 312 | | |
272 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
273 | 324 | | |
274 | 325 | | |
275 | | - | |
| 326 | + | |
276 | 327 | | |
277 | | - | |
| 328 | + | |
278 | 329 | | |
279 | 330 | | |
280 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
396 | 453 | | |
397 | 454 | | |
398 | 455 | | |
| |||
0 commit comments