gitlab-org--gitlab-foss/app/uploaders/artifact_uploader.rb
Robert Speicher a8c62dfe5c Minor refactoring of Uploaders
- Moves a duplicate `file_storage?` definition into the common
  `GitlabUploader` ancestor.
- Get the `uploads` base directory from a class method rather than
  hard-coding it where it's needed. This will be used in a subsequent MR
  to store Uploads in the database.
- Improves the specs for uploaders.
2017-02-24 16:41:27 -05:00

37 lines
679 B
Ruby

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