Commit c4566a3f authored by Matija Čupić's avatar Matija Čupić Committed by Robert Speicher

Gate feature behind FF

parent 25d703d7
...@@ -33,8 +33,7 @@ module Ci ...@@ -33,8 +33,7 @@ module Ci
file_type: params['artifact_type'], file_type: params['artifact_type'],
file_format: params['artifact_format'], file_format: params['artifact_format'],
file_sha256: artifacts_file.sha256, file_sha256: artifacts_file.sha256,
expire_in: expire_in, expire_in: expire_in)
locked: true)
artifact_metadata = if metadata_file artifact_metadata = if metadata_file
Ci::JobArtifact.new( Ci::JobArtifact.new(
...@@ -44,10 +43,14 @@ module Ci ...@@ -44,10 +43,14 @@ module Ci
file_type: :metadata, file_type: :metadata,
file_format: :gzip, file_format: :gzip,
file_sha256: metadata_file.sha256, file_sha256: metadata_file.sha256,
expire_in: expire_in, expire_in: expire_in)
locked: true)
end end
if Feature.enabled?(:keep_latest_artifact_for_ref, job.project)
artifact.locked = true
artifact_metadata.locked = true
end
[artifact, artifact_metadata] [artifact, artifact_metadata]
end end
...@@ -85,6 +88,8 @@ module Ci ...@@ -85,6 +88,8 @@ module Ci
end end
def unlock_previous_artifacts!(artifact) def unlock_previous_artifacts!(artifact)
return unless Feature.enabled?(:keep_latest_artifact_for_ref, artifact.job.project)
Ci::JobArtifact.for_ref(artifact.job.ref, artifact.project_id).locked.update_all(locked: false) Ci::JobArtifact.for_ref(artifact.job.ref, artifact.project_id).locked.update_all(locked: false)
end end
......
...@@ -28,7 +28,13 @@ module Ci ...@@ -28,7 +28,13 @@ module Ci
private private
def destroy_batch def destroy_batch
artifacts = Ci::JobArtifact.expired(BATCH_SIZE).unlocked.to_a artifact_batch = if Feature.enabled?(:keep_latest_artifact_for_ref)
Ci::JobArtifact.expired(BATCH_SIZE).unlocked
else
Ci::JobArtifact.expired(BATCH_SIZE)
end
artifacts = artifact_batch.to_a
return false if artifacts.empty? return false if artifacts.empty?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment