Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/checks/global_file_size_check.rb')
-rw-r--r--lib/gitlab/checks/global_file_size_check.rb33
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?