2018-07-21 20:39:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-11 16:45:16 -04:00
|
|
|
class DeleteDiffFilesWorker
|
|
|
|
include ApplicationWorker
|
|
|
|
|
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
|
|
|
|
merge_request_diff.clean!
|
|
|
|
|
|
|
|
MergeRequestDiffFile
|
|
|
|
.where(merge_request_diff_id: merge_request_diff.id)
|
|
|
|
.delete_all
|
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2018-06-11 16:45:16 -04:00
|
|
|
end
|