2018-07-21 20:39:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class DeleteDiffFilesWorker # rubocop:disable Scalability/IdempotentWorker
|
2018-06-11 16:45:16 -04:00
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-04-30 14:10:09 -04:00
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2020-12-02 13:09:35 -05:00
|
|
|
feature_category :code_review
|
2019-10-18 07:11:44 -04:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-06-11 16:45:16 -04:00
|
|
|
def perform(merge_request_diff_id)
|
|
|
|
merge_request_diff = MergeRequestDiff.find(merge_request_diff_id)
|
|
|
|
|
|
|
|
return if merge_request_diff.without_files?
|
|
|
|
|
|
|
|
MergeRequestDiff.transaction do
|
|
|
|
MergeRequestDiffFile
|
|
|
|
.where(merge_request_diff_id: merge_request_diff.id)
|
|
|
|
.delete_all
|
2020-08-26 08:10:53 -04:00
|
|
|
|
|
|
|
merge_request_diff.clean!
|
2018-06-11 16:45:16 -04:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-06-11 16:45:16 -04:00
|
|
|
end
|