summaryrefslogtreecommitdiff
path: root/app/uploaders/artifact_uploader.rb
blob: e84944ed4116716568b112fbae92d21642edc3a6 (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
28
29
30
31
32
33
34
35
36
37
class ArtifactUploader < GitlabUploader
  storage :file

  attr_accessor :build, :field

  def self.artifacts_path
    Gitlab.config.artifacts.path
  end

  def self.artifacts_upload_path
    File.join(self.artifacts_path, 'tmp/uploads/')
  end

  def self.artifacts_cache_path
    File.join(self.artifacts_path, 'tmp/cache/')
  end

  def initialize(build, field)
    @build, @field = build, field
  end

  def store_dir
    File.join(self.class.artifacts_path, @build.artifacts_path)
  end

  def cache_dir
    File.join(self.class.artifacts_cache_path, @build.artifacts_path)
  end

  def filename
    file.try(:filename)
  end

  def exists?
    file.try(:exists?)
  end
end