Class: Projects::DestroyService
- Inherits:
-
BaseService
- Object
- BaseService
- Projects::DestroyService
- Includes:
- Gitlab::ShellAdapter
- Defined in:
- app/services/projects/destroy_service.rb
Constant Summary collapse
- DestroyError =
Class.new(StandardError)
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods included from Gitlab::ShellAdapter
Methods inherited from BaseService
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
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#async_execute ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/projects/destroy_service.rb', line 9 def async_execute project.update_attribute(:pending_delete, true) # Ensure no repository +deleted paths are kept, # regardless of any issue with the ProjectDestroyWorker # job process. schedule_stale_repos_removal job_id = ProjectDestroyWorker.perform_async(project.id, current_user.id, params) log_info("User #{current_user.id} scheduled destruction of project #{project.full_path} with job ID #{job_id}") end |
#execute ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/services/projects/destroy_service.rb', line 21 def execute return false unless can?(current_user, :remove_project, project) # 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) Projects::UnlinkForkService.new(project, current_user).execute attempt_destroy(project) system_hook_service.execute_hooks_for(project, :destroy) log_info("Project \"#{project.full_path}\" was deleted") current_user.invalidate_personal_projects_count true rescue => error attempt_rollback(project, error.) false rescue Exception => error # rubocop:disable Lint/RescueException # Project.transaction can raise Exception attempt_rollback(project, error.) raise end |