debian-mirror-gitlab/lib/gitlab/checks/lfs_integrity.rb

32 lines
966 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Gitlab
module Checks
class LfsIntegrity
2021-09-04 01:27:46 +05:30
def initialize(project, newrevs, time_left)
2018-03-17 18:26:18 +05:30
@project = project
2021-09-04 01:27:46 +05:30
@newrevs = newrevs
2018-12-13 13:39:08 +05:30
@time_left = time_left
2018-03-17 18:26:18 +05:30
end
def objects_missing?
2021-09-04 01:27:46 +05:30
return false unless @project.lfs_enabled?
2018-03-17 18:26:18 +05:30
2021-09-04 01:27:46 +05:30
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-12-13 13:39:08 +05:30
.new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)
2018-03-17 18:26:18 +05:30
return false unless new_lfs_pointers.present?
2020-11-24 15:15:51 +05:30
existing_count = @project.lfs_objects
2020-04-08 14:13:33 +05:30
.for_oids(new_lfs_pointers.map(&:lfs_oid))
2018-03-17 18:26:18 +05:30
.count
existing_count != new_lfs_pointers.count
end
end
end
end