blob: ca4b70a04859e321f1227e3d8a7e805b0137f350 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# frozen_string_literal: true
class RemoveUnreferencedLfsObjectsWorker
include ApplicationWorker
sidekiq_options retry: 3
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
include CronjobQueue
# rubocop:enable Scalability/CronWorkerContext
feature_category :git_lfs
deduplicate :until_executed
idempotent!
def perform
number_of_removed_files = 0
LfsObject.unreferenced_in_batches do |lfs_objects_without_projects|
number_of_removed_files += lfs_objects_without_projects.destroy_all.count # rubocop: disable Cop/DestroyAll
end
number_of_removed_files
end
end
|