Class: Projects::DestroyService

Inherits:
BaseService show all
Includes:
Gitlab::ShellAdapter
Defined in:
app/services/projects/destroy_service.rb

Defined Under Namespace

Classes: DestroyError

Constant Summary collapse

DELETED_FLAG =
'+deleted'

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::ShellAdapter

#gitlab_shell

Methods inherited from BaseService

#abilities, #can?, #deny_visibility_level, #event_service, #initialize, #log_info, #notification_service, #repository, #system_hook_service, #todo_service

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/projects/destroy_service.rb', line 13

def execute
  return false unless can?(current_user, :remove_project, project)

  project.team.truncate

  repo_path = project.path_with_namespace
  wiki_path = repo_path + '.wiki'

  # Flush the cache for both repositories. This has to be done _before_
  # removing the physical repositories as some expiration code depends on
  # Git data (e.g. a list of branch names).
  flush_caches(project, wiki_path)

  Project.transaction do
    project.destroy!

    unless remove_repository(repo_path)
      raise_error('Failed to remove project repository. Please try again or contact administrator')
    end

    unless remove_repository(wiki_path)
      raise_error('Failed to remove wiki repository. Please try again or contact administrator')
    end
  end

  log_info("Project \"#{project.name}\" was removed")
  system_hook_service.execute_hooks_for(project, :destroy)
  true
end

#pending_delete!Object


9
10
11
# File 'app/services/projects/destroy_service.rb', line 9

def pending_delete!
  project.schedule_delete!(current_user.id, params)
end