Update content_size to be in bytes #3802
Merged
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.
Motivation for changes:
There were several different places we wrote parsing functions for human readable file sizes. I consolidated these into just one main function in our tools package. Doing this, I noticed a mix of dealing with filesizes either in bytes or mebibytes. I've changed everything to just deal in bytes. The main change here was the content_size field. I've updated all the plugins I could find to use the field with bytes, but we'll still need to write an upgrade action and do a version bump in case anyone was using this field manually in their config (or custom plugin.)
Detailed changes:
format_filesizenow takes a number of bytes and outputs a human readable size. This is now used in log methods when showing file sizes.Addressed issues/feature requests:
Config usage if relevant (new plugin or updated schema):
To Do:
Right now sizes in the config are always in binary units with no way to specify metric ones. Should we make binary units require explicitly being specified, to allow for metric specification? i.e. 1 GB would be metric, and 1GiB binary. Currently, they both are binary.This was not explicitly true. Each plugin ends up choosing this themselves. But perhaps we should make the mode that allows metric sizes default, rather than opt-in.