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.

43 lines
1.2 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:
{
destroyed_artifacts_count: result.fetch(:destroyed_artifacts_count),
statistics_updates: result.fetch(:statistics_updates)
})
else
ServiceResponse.error(message: result.fetch(:message))
end
2022-10-11 01:57:18 +05:30
end
private
attr_reader :build
end
end
end