diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 12:11:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-15 12:11:10 +0300 |
commit | 6fe7ad3526d2b84160129f4989e8f9ebfe8ef6b7 (patch) | |
tree | 8d31948e4b4e4ed798f88c8be735c86b7b9bef9b /lib | |
parent | 5e9a1717166c6b9bf0a6cbd00137d5c0043ba442 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/checks/global_file_size_check.rb | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lib/gitlab/checks/global_file_size_check.rb b/lib/gitlab/checks/global_file_size_check.rb index ff24467e9cc..5dc41b2a4cc 100644 --- a/lib/gitlab/checks/global_file_size_check.rb +++ b/lib/gitlab/checks/global_file_size_check.rb @@ -3,6 +3,8 @@ module Gitlab module Checks class GlobalFileSizeCheck < BaseBulkChecker + include ActionView::Helpers::NumberHelper + LOG_MESSAGE = 'Checking for blobs over the file size limit' def validate! @@ -17,31 +19,24 @@ module Gitlab ).find if oversized_blobs.present? - - blob_details = {} - blob_id_size_msg = "" - oversized_blobs.each do |blob| - blob_details[blob.id] = { "size" => blob.size } - - # blob size is in byte, divide it by "/ 1024.0 / 1024.0" to get MiB - blob_id_size_msg += "- #{blob.id} (#{(blob.size / 1024.0 / 1024.0).round(2)} MiB) \n" - end + blob_id_size_msg = oversized_blobs.map do |blob| + "- #{blob.id} (#{number_to_human_size(blob.size)})" + end.join("\n") oversize_err_msg = <<~OVERSIZE_ERR_MSG - You are attempting to check in one or more blobs which exceed the #{file_size_limit}MiB limit: - - #{blob_id_size_msg} - To resolve this error, you must either reduce the size of the above blobs, or utilize LFS. - You may use "git ls-tree -r HEAD | grep $BLOB_ID" to see the file path. - Please refer to #{Rails.application.routes.url_helpers.help_page_url('user/free_push_limit')} and - #{Rails.application.routes.url_helpers.help_page_url('administration/settings/account_and_limit_settings')} - for further information. + You are attempting to check in one or more blobs which exceed the #{file_size_limit}MiB limit: + + #{blob_id_size_msg} + To resolve this error, you must either reduce the size of the above blobs, or utilize LFS. + You may use "git ls-tree -r HEAD | grep $BLOB_ID" to see the file path. + Please refer to #{Rails.application.routes.url_helpers.help_page_url('user/free_push_limit')} and + #{Rails.application.routes.url_helpers.help_page_url('administration/settings/account_and_limit_settings')} + for further information. OVERSIZE_ERR_MSG Gitlab::AppJsonLogger.info( message: 'Found blob over global limit', - blob_sizes: oversized_blobs.map(&:size), - blob_details: blob_details + blob_details: oversized_blobs.map { |blob| { "id" => blob.id, "size" => blob.size } } ) raise ::Gitlab::GitAccess::ForbiddenError, oversize_err_msg if enforce_global_file_size_limit? |