2018-10-11 16:12:21 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-24 21:30:12 -04:00
|
|
|
module Gitlab
|
|
|
|
module Checks
|
|
|
|
class LfsIntegrity
|
2018-10-22 10:49:20 -04:00
|
|
|
def initialize(project, newrev, time_left)
|
2017-08-24 21:30:12 -04:00
|
|
|
@project = project
|
|
|
|
@newrev = newrev
|
2018-10-22 10:49:20 -04:00
|
|
|
@time_left = time_left
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-08-24 21:30:12 -04:00
|
|
|
def objects_missing?
|
|
|
|
return false unless @newrev && @project.lfs_enabled?
|
|
|
|
|
2018-08-07 07:13:48 -04:00
|
|
|
new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev)
|
2018-10-22 10:49:20 -04:00
|
|
|
.new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)
|
2017-08-24 21:30:12 -04:00
|
|
|
|
|
|
|
return false unless new_lfs_pointers.present?
|
|
|
|
|
2018-04-04 10:40:58 -04:00
|
|
|
existing_count = @project.all_lfs_objects
|
2017-11-08 07:59:48 -05:00
|
|
|
.where(oid: new_lfs_pointers.map(&:lfs_oid))
|
|
|
|
.count
|
2017-08-24 21:30:12 -04:00
|
|
|
|
|
|
|
existing_count != new_lfs_pointers.count
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|