diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-01-10 12:32:12 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-04-04 12:19:43 +0300 |
commit | 8e51439e809db6ff5ff86bd79cdf95af62821a1d (patch) | |
tree | 103c4a6602397f03c7d548eb298e02775c21db4b /app/models | |
parent | 74ace2a445a44a13bd22c1907b8ec55b1772d403 (diff) |
Drop legacy artifacts usage
Legacy artifacts have been correctly migrated to new place -
ci_job_artifacts. Now it's time to remove the related code, but before
that we should ensure it doesn't break anything by using feature flag.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 13 | ||||
-rw-r--r-- | app/models/concerns/artifact_migratable.rb | 14 |
2 files changed, 23 insertions, 4 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 1bd517641ac..b8a76e662b0 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -83,8 +83,13 @@ module Ci scope :unstarted, ->() { where(runner_id: nil) } scope :ignore_failures, ->() { where(allow_failure: false) } scope :with_artifacts_archive, ->() do - where('(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)', - '', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').archive) + if Feature.enabled?(:ci_enable_legacy_artifacts) + where('(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)', + '', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').archive) + else + where('EXISTS (?)', + Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').archive) + end end scope :with_existing_job_artifacts, ->(query) do @@ -135,6 +140,8 @@ module Ci where("EXISTS (?)", matcher) end + ## + # TODO: Remove these mounters when we remove :ci_enable_legacy_artifacts feature flag mount_uploader :legacy_artifacts_file, LegacyArtifactUploader, mount_on: :artifacts_file mount_uploader :legacy_artifacts_metadata, LegacyArtifactUploader, mount_on: :artifacts_metadata @@ -775,7 +782,7 @@ module Ci private def erase_old_artifacts! - # TODO: To be removed once we get rid of + # TODO: To be removed once we get rid of ci_enable_legacy_artifacts feature flag remove_artifacts_file! remove_artifacts_metadata! save diff --git a/app/models/concerns/artifact_migratable.rb b/app/models/concerns/artifact_migratable.rb index cbd63ba8876..7c9f579b480 100644 --- a/app/models/concerns/artifact_migratable.rb +++ b/app/models/concerns/artifact_migratable.rb @@ -13,7 +13,7 @@ module ArtifactMigratable end def artifacts? - !artifacts_expired? && artifacts_file.exists? + !artifacts_expired? && artifacts_file&.exists? end def artifacts_metadata? @@ -43,4 +43,16 @@ module ArtifactMigratable def artifacts_size read_attribute(:artifacts_size).to_i + job_artifacts.sum(:size).to_i end + + def legacy_artifacts_file + return unless Feature.enabled?(:ci_enable_legacy_artifacts) + + super + end + + def legacy_artifacts_metadata + return unless Feature.enabled?(:ci_enable_legacy_artifacts) + + super + end end |