Skip to content

Report output write errors, and don't print a size that isn't known - #427

Merged
folbricht merged 1 commit into
masterfrom
fix-output-error-handling
Sep 3, 2026
Merged

Report output write errors, and don't print a size that isn't known#427
folbricht merged 1 commit into
masterfrom
fix-output-error-handling

Conversation

@folbricht

Copy link
Copy Markdown
Owner

MtreeFS discarded the error from every line it wrote and returned nil unconditionally, so desync mtree against output that has stopped accepting writes — a full disk, a closed pipe — produced a truncated listing and exited 0. Each entry now reports its own write, as NewMtreeFS already did for the header.

The plain output of info and the output of chunk went straight to os.Stdout rather than the package writer the JSON branch uses. That is also why neither had any tests; both now do.

info reported a compressed size of 0 in three different situations: when there genuinely was nothing to transfer, when no --chunks-info was given so no estimate was attempted, and when the estimate was deliberately abandoned because the info file was missing a chunk or a compressed size. The last two are "not known", not "zero". The value is now reported only when it was actually worked out, so the JSON field is absent and the plain line missing otherwise.

The plain label read Compressed chunks not in seed nor cache: for what is a byte count, where every sibling size line says "Size of…". It now reads Compressed size of deduplicated chunks not in seed nor cache:.

Note for anyone parsing the JSON: dedup-size-not-in-seed-nor-cache-compressed is now omitted rather than reported as 0 when it could not be estimated. Three of the existing test fixtures expected that zero and no longer carry the field.

MtreeFS discarded the error from every line it wrote and returned nil, so
'desync mtree' against output that stopped accepting writes produced a
truncated listing and exited 0. Each entry now reports its own write.

The plain output of 'info' and the output of 'chunk' went straight to
os.Stdout rather than the package writer the JSON branch uses, which is
also why neither had any tests.

'info' reported a compressed size of 0 both when there was nothing to
transfer and when it had deliberately given up on the estimate, either
because no chunks info file was given or because one was missing a chunk.
Report it only when it was worked out, so the JSON field is absent and
the plain line missing when it isn't known, and label it as the size it
is rather than a count.
@folbricht
folbricht merged commit 9b52269 into master Sep 3, 2026
9 checks passed
@folbricht
folbricht deleted the fix-output-error-handling branch September 3, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant