gitlab-org--gitlab-foss/lib/gitlab/checks/lfs_integrity.rb
Bob Van Landuyt 48b17e991a Add helper for accessing lfs_objects for project
This makes accessing LFS Objects for a project easier

  project.lfs_storage_project.lfs_objects`

becomes

  project.all_lfs_objects

This will make the refactor in
https://gitlab.com/gitlab-org/gitlab-ce/issues/39769 easier to deal
with.
2018-04-05 10:21:51 +02:00

26 lines
717 B
Ruby

module Gitlab
module Checks
class LfsIntegrity
REV_LIST_OBJECT_LIMIT = 2_000
def initialize(project, newrev)
@project = project
@newrev = newrev
end
def objects_missing?
return false unless @newrev && @project.lfs_enabled?
new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev).new_pointers(object_limit: REV_LIST_OBJECT_LIMIT)
return false unless new_lfs_pointers.present?
existing_count = @project.all_lfs_objects
.where(oid: new_lfs_pointers.map(&:lfs_oid))
.count
existing_count != new_lfs_pointers.count
end
end
end
end