Commit e35ecfeb authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'allow_repo_storage_moves_without_repo' into 'master'

Allow project storage to be updated when no repositories exist

See merge request gitlab-org/gitlab!46385
parents 231093b8 d1c72fcc
......@@ -54,7 +54,7 @@ module Projects
end
def mirror_repositories
mirror_repository
mirror_repository if project.repository_exists?
if project.wiki.repository_exists?
mirror_repository(type: Gitlab::GlRepository::WIKI)
......@@ -92,12 +92,14 @@ module Projects
end
def remove_old_paths
Gitlab::Git::Repository.new(
source_storage_name,
"#{project.disk_path}.git",
nil,
nil
).remove
if project.repository_exists?
Gitlab::Git::Repository.new(
source_storage_name,
"#{project.disk_path}.git",
nil,
nil
).remove
end
if project.wiki.repository_exists?
Gitlab::Git::Repository.new(
......
---
title: Allow project storage to be updated when no repositories exist
merge_request: 46385
author:
type: fixed
......@@ -168,6 +168,24 @@ RSpec.describe Projects::UpdateRepositoryStorageService do
end
end
context 'project with no repositories' do
let(:project) { create(:project) }
let(:repository_storage_move) { create(:project_repository_storage_move, :scheduled, project: project, destination_storage_name: 'test_second_storage') }
it 'updates the database' do
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('default').and_call_original
allow(Gitlab::GitalyClient).to receive(:filesystem_id).with('test_second_storage').and_return(SecureRandom.uuid)
result = subject.execute
project.reload
expect(result).to be_success
expect(project).not_to be_repository_read_only
expect(project.repository_storage).to eq('test_second_storage')
expect(project.project_repository.shard_name).to eq('test_second_storage')
end
end
context 'with wiki repository' do
include_examples 'moves repository to another storage', 'wiki' do
let(:project) { create(:project, :repository, wiki_enabled: true) }
......
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