Class: Gitlab::Ci::ArtifactFileReader
- Inherits:
-
Object
- Object
- Gitlab::Ci::ArtifactFileReader
- Defined in:
- lib/gitlab/ci/artifact_file_reader.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
- MAX_ARCHIVE_SIZE =
5.megabytes
- TMP_ARTIFACT_EXTRACTION_DIR =
"extracted_artifacts_job_%{id}"
Instance Method Summary collapse
-
#initialize(job) ⇒ ArtifactFileReader
constructor
A new instance of ArtifactFileReader.
- #read(path) ⇒ Object
Constructor Details
#initialize(job) ⇒ ArtifactFileReader
Returns a new instance of ArtifactFileReader.
14 15 16 17 18 19 20 21 |
# File 'lib/gitlab/ci/artifact_file_reader.rb', line 14 def initialize(job) @job = job raise Error, 'Job doesnt exist' unless @job raise Error, 'Job does not have artifacts' unless @job.artifacts? validate! end |
Instance Method Details
#read(path) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/ci/artifact_file_reader.rb', line 23 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 |