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
|
2018-12-13 13:39:08 +05:30
|
|
|
def initialize(project, newrev, time_left)
|
2018-03-17 18:26:18 +05:30
|
|
|
@project = project
|
|
|
|
@newrev = newrev
|
2018-12-13 13:39:08 +05:30
|
|
|
@time_left = time_left
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def objects_missing?
|
|
|
|
return false unless @newrev && @project.lfs_enabled?
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev)
|
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?
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
existing_count = @project.all_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
|