Report output write errors, and don't print a size that isn't known - #427
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MtreeFSdiscarded the error from every line it wrote and returned nil unconditionally, sodesync mtreeagainst 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, asNewMtreeFSalready did for the header.The plain output of
infoand the output ofchunkwent straight toos.Stdoutrather than the package writer the JSON branch uses. That is also why neither had any tests; both now do.inforeported a compressed size of0in three different situations: when there genuinely was nothing to transfer, when no--chunks-infowas 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 readsCompressed size of deduplicated chunks not in seed nor cache:.Note for anyone parsing the JSON:
dedup-size-not-in-seed-nor-cache-compressedis now omitted rather than reported as0when it could not be estimated. Three of the existing test fixtures expected that zero and no longer carry the field.