debian-mirror-gitlab/app/services/ci/job_artifacts/delete_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.1 KiB
Ruby
Raw Normal View History

2022-10-11 01:57:18 +05:30
# 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
)
2022-11-25 23:54:43 +05:30
return ServiceResponse.error(
message: 'Action temporarily disabled. The project this job belongs to is undergoing stats refresh.',
reason: :project_stats_refresh
)
2022-10-11 01:57:18 +05:30
end
2022-11-25 23:54:43 +05:30
result = Ci::JobArtifacts::DestroyBatchService.new(build.job_artifacts.erasable).execute
2022-10-11 01:57:18 +05:30
2022-11-25 23:54:43 +05:30
if result.fetch(:status) == :success
ServiceResponse.success(payload:
{
2023-03-17 16:20:25 +05:30
destroyed_artifacts_count: result.fetch(:destroyed_artifacts_count)
2022-11-25 23:54:43 +05:30
})
else
ServiceResponse.error(message: result.fetch(:message))
end
2022-10-11 01:57:18 +05:30
end
private
attr_reader :build
end
end
end