2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-05-27 15:10:39 +00:00
|
|
|
class RemoveUnreferencedLfsObjectsWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2020-02-10 12:08:59 +00:00
|
|
|
# rubocop:disable Scalability/CronWorkerContext
|
|
|
|
# This worker does not perform work scoped to a context
|
|
|
|
include CronjobQueue
|
|
|
|
# rubocop:enable Scalability/CronWorkerContext
|
2016-10-28 17:39:20 +00:00
|
|
|
|
2020-02-05 00:08:41 +00:00
|
|
|
feature_category :git_lfs
|
2021-05-27 15:10:39 +00:00
|
|
|
deduplicate :until_executed
|
|
|
|
idempotent!
|
2019-10-18 11:11:44 +00:00
|
|
|
|
2016-10-28 17:39:20 +00:00
|
|
|
def perform
|
2021-05-27 15:10:39 +00:00
|
|
|
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
|
2016-10-28 17:39:20 +00:00
|
|
|
end
|
|
|
|
end
|