BigW Consortium Gitlab

artifact_uploader.rb 862 Bytes
Newer Older
1 2 3 4 5 6 7
# encoding: utf-8
class ArtifactUploader < CarrierWave::Uploader::Base
  storage :file

  attr_accessor :build, :field

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

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

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

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

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

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

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

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

39 40 41 42 43 44 45 46 47 48 49 50
  def exists?
    file.try(:exists?)
  end

  def move_to_cache
    true
  end

  def move_to_store
    true
  end
end