Commit 80221cd4 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'geo-fix-wiki-moving' into 'master'

[Geo] Fix project rename when wiki does not exist

See merge request gitlab-org/gitlab-ee!5076
parents b17e7d7c b805c2d7
......@@ -29,9 +29,25 @@ module Geo
def move_repositories!
project.ensure_storage_path_exists
move_project_repository && move_wiki_repository
unless move_project_repository
log_error('Repository cannot be moved')
return false
end
# We try to move the wiki repo despite the fact the wiki enabled or not
# But we consider the move as failed, only if the wiki is enabled
# If the wiki is disabled but repository exists we need to move it anyway as it
# can be acquired by the different project if later someone will take the same name.
# Once we have hashed storage as the only option this problem will be eliminated
if !move_wiki_repository && project.wiki_enabled?
log_error('Wiki repository cannot be moved')
return false
end
true
rescue => ex
log_error('Repository cannot be renamed', error: ex)
log_error('Repository cannot be moved', error: ex)
false
end
......
---
title: "[Geo] Fix project rename when wiki does not exist"
merge_request:
author:
type: fixed
......@@ -27,6 +27,8 @@ describe Geo::MoveRepositoryService, :geo do
.with(project.repository_storage_path, old_path, new_path)
.and_return(false)
expect(service).to receive(:log_error).with('Repository cannot be moved')
expect(service.execute).to eq false
end
......@@ -39,7 +41,27 @@ describe Geo::MoveRepositoryService, :geo do
.with(project.repository_storage_path, "#{old_path}.wiki", "#{new_path}.wiki")
.and_return(false)
expect(service).to receive(:log_error).with('Wiki repository cannot be moved')
expect(service.execute).to eq false
end
context 'wiki disabled' do
let(:project) { create(:project, :repository, :wiki_disabled, :legacy_storage) }
it 'tries to move wiki even if it is not enabled without reporting error' do
allow_any_instance_of(Gitlab::Shell).to receive(:mv_repository)
.with(project.repository_storage_path, old_path, new_path)
.and_return(true)
allow_any_instance_of(Gitlab::Shell).to receive(:mv_repository)
.with(project.repository_storage_path, "#{old_path}.wiki", "#{new_path}.wiki")
.and_return(false)
expect(service).not_to receive(:log_error)
expect(service.execute).to eq(true)
end
end
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