summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-25 13:34:14 +0000
committerRémy Coutable <remy@rymai.me>2018-05-25 13:34:14 +0000
commite73b71ec9c85b609a31bc71877d2121186325a10 (patch)
treeafb02de81d6523d8cf03cad4b64d46d16ca1859a
parentcc570b6c44b69469ba675e2e66fc14808890201d (diff)
parentc33c9bf6f3e844494823ecaf9be4c9cff66903ec (diff)
downloadgitlab-ce-e73b71ec9c85b609a31bc71877d2121186325a10.tar.gz
Merge branch 'rs-projects-destroy-service-parity' into 'master'
Bring CE-EE parity to app/services/projects/destroy_service.rb See merge request gitlab-org/gitlab-ce!19111
-rw-r--r--app/services/projects/destroy_service.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb
index adbc498d0bf..077d27c5836 100644
--- a/app/services/projects/destroy_service.rb
+++ b/app/services/projects/destroy_service.rb
@@ -51,11 +51,11 @@ module Projects
flush_caches(@project)
- unless mv_repository(removal_path(repo_path), repo_path)
+ unless rollback_repository(removal_path(repo_path), repo_path)
raise_error('Failed to restore project repository. Please contact the administrator.')
end
- unless mv_repository(removal_path(wiki_path), wiki_path)
+ unless rollback_repository(removal_path(wiki_path), wiki_path)
raise_error('Failed to restore wiki repository. Please contact the administrator.')
end
end
@@ -84,6 +84,9 @@ module Projects
# Skip repository removal. We use this flag when remove user or group
return true if params[:skip_repo] == true
+ # There is a possibility project does not have repository or wiki
+ return true unless repo_exists?(path)
+
new_path = removal_path(path)
if mv_repository(path, new_path)
@@ -98,8 +101,18 @@ module Projects
end
end
- def mv_repository(from_path, to_path)
+ def rollback_repository(old_path, new_path)
# There is a possibility project does not have repository or wiki
+ return true unless repo_exists?(old_path)
+
+ mv_repository(old_path, new_path)
+ end
+
+ def repo_exists?(path)
+ gitlab_shell.exists?(project.repository_storage, path + '.git')
+ end
+
+ def mv_repository(from_path, to_path)
return true unless gitlab_shell.exists?(project.repository_storage, from_path + '.git')
gitlab_shell.mv_repository(project.repository_storage, from_path, to_path)