Class: PoolRepository

Inherits:
ApplicationRecord show all
Includes:
AfterCommitQueue, Shardable
Defined in:
app/models/pool_repository.rb

Overview

The PoolRepository model is the database equivalent of an ObjectPool for Gitaly That is; PoolRepository is the record in the database, ObjectPool is the repository on disk

Instance Method Summary collapse

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods included from Shardable

#shard_name, #shard_name=

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#create_object_poolObject


70
71
72
# File 'app/models/pool_repository.rb', line 70

def create_object_pool
  object_pool.create
end

#delete_object_poolObject

The members of the pool should have fetched the missing objects to their own objects directory. If the caller fails to do so, data loss might occur


76
77
78
# File 'app/models/pool_repository.rb', line 76

def delete_object_pool
  object_pool.delete
end

#inspectObject


101
102
103
104
# File 'app/models/pool_repository.rb', line 101

def inspect
  source = source_project ? source_project.full_path : 'nil'
  "#<#{self.class.name} id:#{id} state:#{state} disk_path:#{disk_path} source_project: #{source}>"
end

80
81
82
# File 'app/models/pool_repository.rb', line 80

def link_repository(repository)
  object_pool.link(repository.raw)
end

#mark_obsolete_if_last(repository) ⇒ Object


84
85
86
87
88
89
90
# File 'app/models/pool_repository.rb', line 84

def mark_obsolete_if_last(repository)
  if member_projects.where.not(id: repository.project.id).exists?
    true
  else
    mark_obsolete
  end
end

#object_poolObject


92
93
94
95
96
97
98
99
# File 'app/models/pool_repository.rb', line 92

def object_pool
  @object_pool ||= Gitlab::Git::ObjectPool.new(
    shard.name,
    disk_path + '.git',
    source_project.repository.raw,
    source_project.full_path
  )
end