Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-09-04 18:40:20 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2018-09-04 18:40:20 +0300
commitf17e48c84ebf3eb9a65f396f48195caad30dcb64 (patch)
treeb8d067825300b1bb45b25f5ca3219f89f05b043f /app/uploaders
parent13f557d0b86667eb35d4170af55bc874ac22f845 (diff)
parentffa2637a0cfabf269c0ab6bd4f7ac6e56fb5c66d (diff)
Merge branch 'add-background-migration-for-legacy-traces' into 'master'
Migrate job artifacts data from `ci_builds` to `ci_job_artifacts` table (with Background migrations) Closes #46652 See merge request gitlab-org/gitlab-ce!18615
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/job_artifact_uploader.rb17
1 files changed, 15 insertions, 2 deletions
diff --git a/app/uploaders/job_artifact_uploader.rb b/app/uploaders/job_artifact_uploader.rb
index f6af023e0f9..557b13a8bd6 100644
--- a/app/uploaders/job_artifact_uploader.rb
+++ b/app/uploaders/job_artifact_uploader.rb
@@ -5,6 +5,7 @@ class JobArtifactUploader < GitlabUploader
include ObjectStorage::Concern
ObjectNotReadyError = Class.new(StandardError)
+ UnknownFileLocationError = Class.new(StandardError)
storage_options Gitlab.config.artifacts
@@ -23,10 +24,22 @@ class JobArtifactUploader < GitlabUploader
def dynamic_segment
raise ObjectNotReadyError, 'JobArtifact is not ready' unless model.id
- creation_date = model.created_at.utc.strftime('%Y_%m_%d')
+ if model.hashed_path?
+ hashed_path
+ elsif model.legacy_path?
+ legacy_path
+ else
+ raise UnknownFileLocationError
+ end
+ end
+ def hashed_path
File.join(disk_hash[0..1], disk_hash[2..3], disk_hash,
- creation_date, model.job_id.to_s, model.id.to_s)
+ model.created_at.utc.strftime('%Y_%m_%d'), model.job_id.to_s, model.id.to_s)
+ end
+
+ def legacy_path
+ File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.job_id.to_s)
end
def disk_hash