Class: Gitlab::Checks::LfsIntegrity

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/checks/lfs_integrity.rb

Instance Method Summary collapse

Constructor Details

#initialize(project, newrev, time_left) ⇒ LfsIntegrity

Returns a new instance of LfsIntegrity.


6
7
8
9
10
# File 'lib/gitlab/checks/lfs_integrity.rb', line 6

def initialize(project, newrev, time_left)
  @project = project
  @newrev = newrev
  @time_left = time_left
end

Instance Method Details

#objects_missing?Boolean

Returns:

  • (Boolean)

12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/checks/lfs_integrity.rb', line 12

def objects_missing?
  return false unless @newrev && @project.lfs_enabled?

  new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev)
                                            .new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)

  return false unless new_lfs_pointers.present?

  existing_count = @project.all_lfs_objects
                           .for_oids(new_lfs_pointers.map(&:lfs_oid))
                           .count

  existing_count != new_lfs_pointers.count
end