Class: Repositories::DestroyService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Repositories::DestroyService
- Defined in:
- app/services/repositories/destroy_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
Methods inherited from BaseService
#ignore_git_errors, #initialize, #move_error, #mv_repository, #repo_exists?
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 Repositories::BaseService
Instance Method Details
#execute ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/repositories/destroy_service.rb', line 4 def execute return success unless repository return success unless repo_exists?(disk_path) # 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). ignore_git_errors { repository.before_delete } # Use variables that aren't methods on Project, because they are used in a callback current_storage = repository.shard current_path = "#{disk_path}.git" # Because #remove happens inside a run_after_commit callback it will # never be triggered on a read-only instance. # # Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/223272 if Gitlab::Database.read_only? Gitlab::Git::Repository.new(current_storage, current_path, nil, nil).remove else container.run_after_commit do Gitlab::Git::Repository.new(current_storage, current_path, nil, nil).remove end end log_info("Repository \"#{full_path}\" was removed") success rescue Gitlab::Git::Repository::NoRepository success end |