summaryrefslogtreecommitdiff
path: root/app/services/ci/job_artifacts/delete_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/ci/job_artifacts/delete_service.rb')
-rw-r--r--app/services/ci/job_artifacts/delete_service.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/services/ci/job_artifacts/delete_service.rb b/app/services/ci/job_artifacts/delete_service.rb
new file mode 100644
index 00000000000..65cae03312e
--- /dev/null
+++ b/app/services/ci/job_artifacts/delete_service.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Ci
+ module JobArtifacts
+ class DeleteService
+ include BaseServiceUtility
+
+ def initialize(build)
+ @build = build
+ end
+
+ def execute
+ if build.project.refreshing_build_artifacts_size?
+ Gitlab::ProjectStatsRefreshConflictsLogger.warn_artifact_deletion_during_stats_refresh(
+ method: 'Ci::JobArtifacts::DeleteService#execute',
+ project_id: build.project_id
+ )
+ end
+
+ # fix_expire_at is false because in this case we want to explicitly delete the job artifacts
+ # this flag is a workaround that will be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/355833
+ Ci::JobArtifacts::DestroyBatchService.new(build.job_artifacts.erasable, fix_expire_at: false).execute
+
+ ServiceResponse.success
+ end
+
+ private
+
+ attr_reader :build
+ end
+ end
+end