2018-10-11 16:12:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-24 21:30:12 -04:00
|
|
|
module Gitlab
|
|
|
|
module Checks
|
|
|
|
class LfsIntegrity
|
2021-06-15 14:09:57 -04:00
|
|
|
def initialize(project, newrevs, time_left)
|
2017-08-24 21:30:12 -04:00
|
|
|
@project = project
|
2021-06-15 14:09:57 -04:00
|
|
|
@newrevs = newrevs
|
2018-10-22 10:49:20 -04:00
|
|
|
@time_left = time_left
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def objects_missing?
|
2021-06-15 14:09:57 -04:00
|
|
|
return false unless @project.lfs_enabled?
|
2017-08-24 21:30:12 -04:00
|
|
|
|
2021-06-15 14:09:57 -04:00
|
|
|
newrevs = @newrevs.reject { |rev| rev.blank? || Gitlab::Git.blank_ref?(rev) }
|
|
|
|
return if newrevs.blank?
|
|
|
|
|
|
|
|
new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, newrevs)
|
2018-10-22 10:49:20 -04:00
|
|
|
.new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)
|
2017-08-24 21:30:12 -04:00
|
|
|
|
|
|
|
return false unless new_lfs_pointers.present?
|
|
|
|
|
2020-09-15 08:09:30 -04:00
|
|
|
existing_count = @project.lfs_objects
|
2020-02-21 16:08:57 -05:00
|
|
|
.for_oids(new_lfs_pointers.map(&:lfs_oid))
|
2017-11-08 07:59:48 -05:00
|
|
|
.count
|
2017-08-24 21:30:12 -04:00
|
|
|
|
|
|
|
existing_count != new_lfs_pointers.count
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|