Class: Projects::GitDeduplicationService

Inherits:
BaseService show all
Includes:
ExclusiveLeaseGuard
Defined in:
app/services/projects/git_deduplication_service.rb

Constant Summary collapse

LEASE_TIMEOUT =
86400

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params

Instance Method Summary collapse

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_release?, #log_error, #release_lease, #renew_lease!, #try_obtain_lease

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(project) ⇒ GitDeduplicationService

Returns a new instance of GitDeduplicationService.


12
13
14
# File 'app/services/projects/git_deduplication_service.rb', line 12

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project


10
11
12
# File 'app/services/projects/git_deduplication_service.rb', line 10

def project
  @project
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/projects/git_deduplication_service.rb', line 16

def execute
  try_obtain_lease do
    unless project.has_pool_repository?
      disconnect_git_alternates
      break
    end

    if source_project? && pool_can_fetch_from_source?
      fetch_from_source
    end

    project.link_pool_repository if same_storage_as_pool?(project.repository)
  end
end