diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-11-23 18:57:27 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-12-03 14:04:49 +0300 |
commit | 871de0f18581bb03fed5c0d800f8183598a0195f (patch) | |
tree | 5b5ac2aadd2a7d58f5e4c845ee85141ee96241a3 /app | |
parent | e2242cdf75d2734f78f694ab3191fcbb31947a6f (diff) |
Rename artifacts_* to legacy_artifacts_*
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/artifact_migratable.rb | 14 | ||||
-rw-r--r-- | app/uploaders/artifact_uploader.rb | 39 | ||||
-rw-r--r-- | app/uploaders/job_artifact_uploader.rb | 18 | ||||
-rw-r--r-- | app/uploaders/legacy_artifact_uploader.rb | 33 |
5 files changed, 49 insertions, 59 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 161800e9061..91747da28a1 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -46,8 +46,8 @@ module Ci scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) } scope :ref_protected, -> { where(protected: true) } - mount_uploader :artifacts_file, ArtifactUploader - mount_uploader :artifacts_metadata, ArtifactUploader + mount_uploader :legacy_artifacts_file, LegacyArtifactUploader, mount_on: :artifacts_file + mount_uploader :legacy_artifacts_metadata, LegacyArtifactUploader, mount_on: :artifacts_metadata acts_as_taggable diff --git a/app/models/concerns/artifact_migratable.rb b/app/models/concerns/artifact_migratable.rb index 8e331617cfa..5c647bacf1b 100644 --- a/app/models/concerns/artifact_migratable.rb +++ b/app/models/concerns/artifact_migratable.rb @@ -3,11 +3,15 @@ # Meant to be prepended so the interface can stay the same module ArtifactMigratable def artifacts_file - job_archive&.file || super + job_archive&.file || legacy_artifacts_file + end + + def artifacts_file? + job_archive&.file? || legacy_artifacts_file? end def artifacts_metadata - job_metadata&.file || super + job_metadata&.file || legacy_artifacts_metadata end def artifacts? @@ -19,14 +23,14 @@ module ArtifactMigratable end def artifacts_file_changed? - job_archive&.file_changed? || super + job_archive&.file_changed? || attribute_changed?(:artifacts_file) end def remove_artifacts_file! if job_archive job_archive.destroy else - super + remove_legacy_artifacts_file! end end @@ -34,7 +38,7 @@ module ArtifactMigratable if job_metadata job_metadata.destroy else - super + remove_legacy_artifacts_metadata! end end diff --git a/app/uploaders/artifact_uploader.rb b/app/uploaders/artifact_uploader.rb deleted file mode 100644 index 14addb6cf14..00000000000 --- a/app/uploaders/artifact_uploader.rb +++ /dev/null @@ -1,39 +0,0 @@ -class ArtifactUploader < GitlabUploader - storage :file - - attr_reader :job, :field - - def self.local_artifacts_store - Gitlab.config.artifacts.path - end - - def self.artifacts_upload_path - File.join(self.local_artifacts_store, 'tmp/uploads/') - end - - def initialize(job, field) - @job, @field = job, field - end - - def store_dir - default_local_path - end - - def cache_dir - File.join(self.class.local_artifacts_store, 'tmp/cache') - end - - def work_dir - File.join(self.class.local_artifacts_store, 'tmp/work') - end - - private - - def default_local_path - File.join(self.class.local_artifacts_store, default_path) - end - - def default_path - File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s) - end -end diff --git a/app/uploaders/job_artifact_uploader.rb b/app/uploaders/job_artifact_uploader.rb index 8a5200504fc..d54411e198f 100644 --- a/app/uploaders/job_artifact_uploader.rb +++ b/app/uploaders/job_artifact_uploader.rb @@ -9,30 +9,22 @@ class JobArtifactUploader < GitlabUploader File.join(self.local_artifacts_store, 'tmp/uploads/') end - def initialize(artifact, _field) - @artifact = artifact - end - def size - return super if @artifact.size.nil? - - @artifact.size - end + return super if model.size.nil? - def store_dir - File.join(self.class.local_artifacts_store, default_path) + model.size end private def default_path - creation_date = @artifact.created_at.utc.strftime('%Y_%m_%d') + creation_date = model.created_at.utc.strftime('%Y_%m_%d') File.join(disk_hash[0..1], disk_hash[2..3], disk_hash, - creation_date, @artifact.job_id.to_s, @artifact.id.to_s) + creation_date, model.job_id.to_s, model.id.to_s) end def disk_hash - @disk_hash ||= Digest::SHA2.hexdigest(@artifact.project_id.to_s) + @disk_hash ||= Digest::SHA2.hexdigest(model.project_id.to_s) end end diff --git a/app/uploaders/legacy_artifact_uploader.rb b/app/uploaders/legacy_artifact_uploader.rb new file mode 100644 index 00000000000..0c23e05b680 --- /dev/null +++ b/app/uploaders/legacy_artifact_uploader.rb @@ -0,0 +1,33 @@ +class LegacyArtifactUploader < GitlabUploader + storage :file + + def self.local_store_path + Gitlab.config.artifacts.path + end + + def self.artifacts_upload_path + File.join(self.local_artifacts_store, 'tmp/uploads/') + end + + def store_dir + default_local_path + end + + def cache_dir + File.join(self.class.local_store_path, 'tmp/cache') + end + + def work_dir + File.join(self.class.local_store_path, 'tmp/work') + end + + private + + def default_local_path + File.join(self.class.local_store_path, default_path) + end + + def default_path + File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.id.to_s) + end +end |