BigW Consortium Gitlab

artifact_uploader.rb 759 Bytes
Newer Older
1
class ArtifactUploader < GitlabUploader
2 3 4 5 6
  storage :file

  attr_accessor :build, :field

  def self.artifacts_path
7
    Gitlab.config.artifacts.path
8 9 10
  end

  def self.artifacts_upload_path
11
    File.join(self.artifacts_path, 'tmp/uploads/')
12 13 14
  end

  def self.artifacts_cache_path
15
    File.join(self.artifacts_path, 'tmp/cache/')
16 17 18 19 20 21 22
  end

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

  def store_dir
23
    File.join(self.class.artifacts_path, @build.artifacts_path)
24 25 26
  end

  def cache_dir
27
    File.join(self.class.artifacts_cache_path, @build.artifacts_path)
28 29 30 31 32 33
  end

  def file_storage?
    self.class.storage == CarrierWave::Storage::File
  end

34 35 36 37
  def filename
    file.try(:filename)
  end

38 39 40 41
  def exists?
    file.try(:exists?)
  end
end