Class: Gitlab::Ci::ArtifactFileReader

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/artifact_file_reader.rb

Constant Summary collapse

Error =
Class.new(StandardError)
MAX_ARCHIVE_SIZE =
5.megabytes

Instance Method Summary collapse

Constructor Details

#initialize(job) ⇒ ArtifactFileReader

Returns a new instance of ArtifactFileReader.

Raises:

  • (ArgumentError)

13
14
15
16
17
18
19
# File 'lib/gitlab/ci/artifact_file_reader.rb', line 13

def initialize(job)
  @job = job

  raise ArgumentError, 'Job does not have artifacts' unless @job.artifacts?

  validate!
end

Instance Method Details

#read(path) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/ci/artifact_file_reader.rb', line 21

def read(path)
  return unless job.

   = job.(path)

  if .total_size > MAX_ARCHIVE_SIZE
    raise Error, "Artifacts archive for job `#{job.name}` is too large: max #{max_archive_size_in_mb}"
  end

  read_zip_file!(path)
end