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

28 lines
853 B
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
module Gitlab
module Checks
class LfsIntegrity
def initialize(project, newrev)
@project = project
@newrev = newrev
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2018-03-17 18:26:18 +05:30
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)
.new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT)
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
2018-03-17 18:26:18 +05:30
.where(oid: new_lfs_pointers.map(&:lfs_oid))
.count
existing_count != new_lfs_pointers.count
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2018-03-17 18:26:18 +05:30
end
end
end