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:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2017-09-21 11:34:12 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-12-03 14:04:48 +0300
commit61864a5a5bb523953589c9398a431c4369fbfc76 (patch)
tree5eac32ef8155e9066d7d1488d7856e83605aa6a5 /app/uploaders
parent25df666156279e5b392b429519b4f4ba01eefaac (diff)
Rename Artifact to JobArtifact, split metadata out
Two things at ones, as there was no clean way to seperate the commit and give me feedback from the tests. But the model Artifact is now JobArtifact, and the table does not have a type anymore, but the metadata is now its own model: Ci::JobArtifactMetadata.
Diffstat (limited to 'app/uploaders')
-rw-r--r--app/uploaders/artifact_uploader.rb8
-rw-r--r--app/uploaders/job_artifact_uploader.rb34
2 files changed, 37 insertions, 5 deletions
diff --git a/app/uploaders/artifact_uploader.rb b/app/uploaders/artifact_uploader.rb
index 8ac0e2fe5a2..d4dda8e9e67 100644
--- a/app/uploaders/artifact_uploader.rb
+++ b/app/uploaders/artifact_uploader.rb
@@ -12,10 +12,6 @@ class ArtifactUploader < GitlabUploader
end
def initialize(job, field)
- # Temporairy conditional, needed to move artifacts to their own table,
- # but keeping compat with Ci::Build for the time being
- job = job.build if job.respond_to?(:build)
-
@job, @field = job, field
end
@@ -38,6 +34,8 @@ class ArtifactUploader < GitlabUploader
end
def default_path
- File.join(job.created_at.utc.strftime('%Y_%m'), job.project_id.to_s, job.id.to_s)
+ File.join(job.project_id.to_s,
+ job.created_at.utc.strftime('%Y_%m'),
+ job.id.to_s)
end
end
diff --git a/app/uploaders/job_artifact_uploader.rb b/app/uploaders/job_artifact_uploader.rb
new file mode 100644
index 00000000000..6ea6a85b4a2
--- /dev/null
+++ b/app/uploaders/job_artifact_uploader.rb
@@ -0,0 +1,34 @@
+class JobArtifactUploader < ArtifactUploader
+ def initialize(artifact, _field)
+ @artifact = artifact
+ end
+
+ # If this record exists, the associatied artifact is there. Every artifact
+ # persisted will have an associated file
+ def exists?
+ true
+ end
+
+ def size
+ return super unless @artifact.size
+
+ @artifact.size
+ end
+
+ private
+
+ def disk_hash
+ @disk_hash ||= Digest::SHA2.hexdigest(job.project_id.to_s)
+ end
+
+ def default_path
+ creation_date = job.created_at.utc.strftime('%Y_%m_%d')
+
+ File.join(disk_hash[0..1], disk_hash[2..3], disk_hash,
+ creation_date, job.id.to_s, @artifact.id.to_s)
+ end
+
+ def job
+ @artifact.job
+ end
+end