diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 06:08:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 06:08:39 +0300 |
commit | 5cef625594aedbac12011d870719fe81a1587a98 (patch) | |
tree | 147d465fb4275ab2d14be99ed58888ca23e10111 /app/services/projects/destroy_rollback_service.rb | |
parent | ee7de3a24d62376916d78649d7e477a184b2e203 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/projects/destroy_rollback_service.rb')
-rw-r--r-- | app/services/projects/destroy_rollback_service.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/services/projects/destroy_rollback_service.rb b/app/services/projects/destroy_rollback_service.rb new file mode 100644 index 00000000000..7f0ca63a406 --- /dev/null +++ b/app/services/projects/destroy_rollback_service.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Projects + class DestroyRollbackService < BaseService + include Gitlab::ShellAdapter + + def execute + return unless project + + Projects::ForksCountService.new(project).delete_cache + + unless rollback_repository(project.repository) + raise_error(s_('DeleteProject|Failed to restore project repository. Please contact the administrator.')) + end + + unless rollback_repository(project.wiki.repository) + raise_error(s_('DeleteProject|Failed to restore wiki repository. Please contact the administrator.')) + end + end + + private + + def rollback_repository(repository) + return true unless repository + + result = Repositories::DestroyRollbackService.new(repository).execute + + result[:status] == :success + end + end +end |