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)
- BATCH_SIZE =
100
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
10 11 12 13 14 15 |
# File 'app/services/projects/destroy_service.rb', line 10 def async_execute project.update_attribute(:pending_delete, true) 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
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 42 43 44 45 46 47 48 49 |
# File 'app/services/projects/destroy_service.rb', line 17 def execute return false unless can?(current_user, :remove_project, project) project.update_attribute(:pending_delete, true) # 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) ::Ci::AbortPipelinesService.new.execute(project.all_pipelines, :project_deleted) 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") publish_project_deleted_event_for(project) project.invalidate_personal_projects_count_of_owner true rescue StandardError => error context = Gitlab::ApplicationContext.current.merge(project_id: project.id) Gitlab::ErrorTracking.track_exception(error, **context) attempt_rollback(project, error.) false rescue Exception => error # rubocop:disable Lint/RescueException # Project.transaction can raise Exception attempt_rollback(project, error.) raise end |