diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2019-03-12 16:04:05 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2019-03-12 16:04:05 +0300 |
commit | ae9838d03556a15d5543a9c42a97d5cf6e3085e9 (patch) | |
tree | 7dc90be384b4c87f1c78ffeaf5ae465ab353dbfa /lib/gitlab/utils.rb | |
parent | 018fc6c696bc2f557211102b163154439b1fc589 (diff) |
Backport try_megabytes_to_bytes from EE
EE adds this method to Gitlab::Utils, which is also required by our
SimpleCov helper. This prevents us from injecting EE modules into
Gitlab::Utils, because the necessary bits for this are not yet in place.
To work around this we just backport try_megabytes_to_bytes, as there's
no particular reason to keep this in EE only.
Diffstat (limited to 'lib/gitlab/utils.rb')
-rw-r--r-- | lib/gitlab/utils.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb index 99fa65e0e90..16ec8a8bb28 100644 --- a/lib/gitlab/utils.rb +++ b/lib/gitlab/utils.rb @@ -104,6 +104,12 @@ module Gitlab nil end + def try_megabytes_to_bytes(size) + Integer(size).megabytes + rescue ArgumentError + size + end + def bytes_to_megabytes(bytes) bytes.to_f / Numeric::MEGABYTE end |