2015-10-12 17:47:32 -04:00
|
|
|
class ArtifactUploader < CarrierWave::Uploader::Base
|
|
|
|
storage :file
|
|
|
|
|
|
|
|
attr_accessor :build, :field
|
|
|
|
|
|
|
|
def self.artifacts_path
|
2015-11-22 08:27:30 -05:00
|
|
|
Gitlab.config.artifacts.path
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.artifacts_upload_path
|
2015-11-22 08:27:30 -05:00
|
|
|
File.join(self.artifacts_path, 'tmp/uploads/')
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.artifacts_cache_path
|
2015-11-22 08:27:30 -05:00
|
|
|
File.join(self.artifacts_path, 'tmp/cache/')
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(build, field)
|
|
|
|
@build, @field = build, field
|
|
|
|
end
|
|
|
|
|
|
|
|
def store_dir
|
2015-12-29 02:52:06 -05:00
|
|
|
File.join(self.class.artifacts_path, @build.artifacts_path)
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def cache_dir
|
2015-12-29 02:52:06 -05:00
|
|
|
File.join(self.class.artifacts_cache_path, @build.artifacts_path)
|
2015-10-12 17:47:32 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def file_storage?
|
|
|
|
self.class.storage == CarrierWave::Storage::File
|
|
|
|
end
|
|
|
|
|
2016-01-14 13:45:43 -05:00
|
|
|
def filename
|
|
|
|
file.try(:filename)
|
|
|
|
end
|
|
|
|
|
2015-10-12 17:47:32 -04:00
|
|
|
def exists?
|
|
|
|
file.try(:exists?)
|
|
|
|
end
|
|
|
|
|
|
|
|
def move_to_cache
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def move_to_store
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|