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.
This commit is contained in:
Gabriel Mazetto 2019-02-22 09:12:06 +01:00
parent fc0ff92807
commit 4bae61005d
3 changed files with 22 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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