Fix Projects::DestroyService#remove_repository

parent d7053e15
...@@ -52,11 +52,11 @@ module Projects ...@@ -52,11 +52,11 @@ module Projects
flush_caches(@project) 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.') raise_error('Failed to restore project repository. Please contact the administrator.')
end 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.') raise_error('Failed to restore wiki repository. Please contact the administrator.')
end end
end end
...@@ -85,6 +85,9 @@ module Projects ...@@ -85,6 +85,9 @@ module Projects
# Skip repository removal. We use this flag when remove user or group # Skip repository removal. We use this flag when remove user or group
return true if params[:skip_repo] == true 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) new_path = removal_path(path)
if mv_repository(path, new_path) if mv_repository(path, new_path)
...@@ -99,10 +102,18 @@ module Projects ...@@ -99,10 +102,18 @@ module Projects
end end
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 # There is a possibility project does not have repository or wiki
return true unless gitlab_shell.exists?(project.repository_storage_path, from_path + '.git') 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, path + '.git')
end
def mv_repository(from_path, to_path)
gitlab_shell.mv_repository(project.repository_storage_path, from_path, to_path) gitlab_shell.mv_repository(project.repository_storage_path, from_path, to_path)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment