Commit 4bae6100 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Edge case: upgrade/downgrade when repository doesn't exist

This change takes the case where repository doesn't exist on disk
and make it ignore but succeed the step, increasing or decreasing the
version depending on the operation.
parent fc0ff928
......@@ -38,7 +38,8 @@ module Projects
# project was not originally empty.
if !from_exists && !to_exists
logger.warn "Can't find a repository on either source or target paths for #{project.full_path} (ID=#{project.id}) ..."
return false
return true
elsif !from_exists
# Repository have been moved already.
return true
......
......@@ -32,6 +32,16 @@ describe Projects::HashedStorage::MigrateRepositoryService do
end
end
context 'when repository doesnt exist on disk' do
let(:project) { create(:project, :legacy_storage) }
it 'skips the disk change but increase the version' do
service.execute
expect(project.hashed_storage?(:repository)).to be_truthy
end
end
context 'when succeeds' do
it 'renames project and wiki repositories' do
service.execute
......
......@@ -34,6 +34,16 @@ describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab_redis
end
end
context 'when repository doesnt exist on disk' do
let(:project) { create(:project) }
it 'skips the disk change but decrease the version' do
service.execute
expect(project.legacy_storage?).to be_truthy
end
end
context 'when succeeds' do
it 'renames project and wiki repositories' do
service.execute
......
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