hexpm / hex_core

Reference implementation of Hex specifications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hex_tarball enhancment: Report max size in error or provide functions to obtain max size(s)

starbelly opened this issue · comments

We have a need in rebar3_hex to report to the user what the max size allowed for a package is. There are at least 4 ways I can see to do this :

  1. update hex_tarball:create/2 to return {error, {tarball, too_big, ?TARBALL_MAX_SIZE}}, ?TARBALL_MAX_UNCOMPRESSED_SIZE}}
  2. hex_core could formulate an error message and return that {error, {tarball, too_big, Msg}}
  3. hex_core could maybe standardize on maps as the second element in an error tuple and put messages, sizes, etc. in said map. {error, #{}}or {error, {tarball, #{}}}
  4. hex_core couldhex_tarball:max_size/0 or hex_tarball:max_compressed_size/0 and hex_tarball:max_uncompressed_size/0 and consumers of hex_core would simply refer to these functions to assist in formulating a message.

It's probably easiest to just provide a function that returns a max size. I'm also wondering if we can get away with just telling the user in an error message only the compressed size (absolute max size), as it gets confusing once you start trying to explain compressed size and uncompressed size in an error message. Perhaps giving the user the uncompressed max size is more helpful vs the compressed max size.

Happy to do a PR, but figured a little discussion around this first would be proper.

I would like to return {error, {tarball, {too_big_uncompressed, ?TARBALL_MAX_UNCOMPRESSED_SIZE}}} and {error, {tarball, {too_big_compressed, ?TARBALL_MAX_SIZE}}}.

The error message needs to differentiate between compressed and uncompressed size because ignoring the difference would likely be even more confusing to users.