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

31 lines
955 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
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
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)
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
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