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

any_oversized_blobs.rb « file_size_check « checks « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 35f969dbb46fa45d890dee9ada1795fcd18a9603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Gitlab
  module Checks
    module FileSizeCheck
      class AnyOversizedBlobs
        def initialize(project:, changes:, file_size_limit_megabytes:)
          @project = project
          @newrevs = changes.pluck(:newrev).compact # rubocop:disable CodeReuse/ActiveRecord just plucking from an array
          @file_size_limit_megabytes = file_size_limit_megabytes
        end

        def find(timeout: nil)
          blobs = project.repository.new_blobs(newrevs, dynamic_timeout: timeout)

          blobs.select do |blob|
            ::Gitlab::Utils.bytes_to_megabytes(blob.size) > file_size_limit_megabytes
          end
        end

        private

        attr_reader :project, :newrevs, :file_size_limit_megabytes
      end
    end
  end
end