fix(pipeline): MP1b - remove dead try/catch in PakWriter.Dispose

Self-review finding: Dispose()'s best-effort Finish() call was wrapped
in a try/catch for InvalidOperationException that could never fire —
the surrounding `if (!_finished)` guard already excludes the only
condition under which Finish() throws that exception. Dead defensive
code that LOOKS like it might be swallowing a real failure is exactly
the kind of thing the no-workarounds policy asks to avoid; removed with
a comment explaining why no catch is needed. Behavior unchanged; 43/43
Content.Tests still green.
This commit is contained in:
Erik 2026-07-05 21:35:07 +02:00
parent 55f16a0205
commit a5926ebcfc

View file

@ -93,12 +93,12 @@ public sealed class PakWriter : IDisposable {
} }
public void Dispose() { public void Dispose() {
// Best-effort finalize so a forgotten Finish() call doesn't leave a
// half-written file with a placeholder header claiming 0 entries
// while blobs are on disk. No try/catch needed: Finish() only throws
// when _finished is already true, which this guard already excludes.
if (!_finished) { if (!_finished) {
// Best-effort finalize so a forgotten Finish() call doesn't leave a Finish();
// half-written file with a placeholder header claiming 0 entries
// while blobs are on disk — surfaced loudly instead via Finish()'s
// own invariants on next use, but here we simply flush what exists.
try { Finish(); } catch (InvalidOperationException) { /* already finished */ }
} }
_stream.Dispose(); _stream.Dispose();
} }