Commit 7a8e2f3
committed
backup: PR810 r5 — coderabbit Major (Close error on WriteChecksums)
Coderabbit r5 Major (checksums.go:82): WriteChecksums returned
out.Sync() but discarded the deferred out.Close() error. Same
shape as the r4 gemini medium on emitManifest, applied here too.
On NFS / some FUSE backends Close is where buffered-writeback
failures surface, so a swallowed Close means the CLI can declare
success on a truncated or unreadable CHECKSUMS file.
Fix: explicit Sync() then Close() with both errors propagated,
with the pre-existing defer'd Close swallowed only on the
error-return paths (the primary failure has already been
surfaced). Extracted writeAllChecksumLines so the parent stays
a thin open / write / sync / close skeleton with the durability
contract spelled out.
Caller audit (CLAUDE.md "semantic-change → grep all callers"):
- WriteChecksums has one caller
(cmd/elastickv-snapshot-decode/main.go:253), which already
surfaces the returned error verbatim via errors.Wrap. The
semantic tightening (Close errors now surface) is honored
by the existing wrapping; no caller change needed.
Also addresses coderabbit r5 nitpick: typed-sentinel assertion
in TestVerifyChecksums_DetectsTampering (was checking err !=
nil generically; now pins ErrChecksumMismatch so a future
change that turns the tamper signal into a different error
class surfaces as a test failure).
Self-review:
1. Data loss — fix prevents silent CHECKSUMS-truncation on
NFS / FUSE.
2. Concurrency — none.
3. Performance — no new I/O; just surfaces an existing error.
4. Data consistency — durability contract now honest.
5. Test coverage — typed-sentinel assertion added; existing
round-trip tests still pass.1 parent ec358ab commit 7a8e2f3
2 files changed
Lines changed: 39 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
76 | 102 | | |
77 | 103 | | |
78 | | - | |
| 104 | + | |
79 | 105 | | |
80 | 106 | | |
81 | 107 | | |
82 | | - | |
| 108 | + | |
83 | 109 | | |
84 | 110 | | |
85 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
112 | 116 | | |
113 | 117 | | |
114 | 118 | | |
115 | | - | |
| 119 | + | |
| 120 | + | |
116 | 121 | | |
117 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
118 | 126 | | |
119 | 127 | | |
120 | 128 | | |
| |||
0 commit comments