Fix bug importing wikis and multiple shards

parent 4214e1c1
# frozen_string_literal: true
module EE
module Gitlab
module ImportExport
module RepoRestorer
extend ::Gitlab::Utils::Override
private
override :update_importable_repository_info
def update_importable_repository_info
return super unless importable.is_a?(GroupWiki)
# At this point, the repo has been created but we
# need to track the repository shard instantiated
# inside the repository object.
importable.track_wiki_repository(repository.shard)
end
end
end
end
end
......@@ -44,7 +44,7 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do
it 'restores the repo successfully', :aggregated_failures do
expect(group.wiki_repository_exists?).to be false
restorer.restore
expect { restorer.restore }.to change { GroupWikiRepository.count }.by(1)
pages = group.wiki.list_pages(load_content: true)
expect(pages.size).to eq 1
......@@ -59,6 +59,7 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do
it 'does not creates an empty wiki' do
expect(restorer.restore).to be true
expect(group.wiki_repository_exists?).to be false
expect(group.group_wiki_repository).to be_nil
end
end
end
......
......@@ -19,6 +19,9 @@ module Gitlab
ensure_repository_does_not_exist!
repository.create_from_bundle(path_to_bundle)
update_importable_repository_info
true
rescue => e
shared.error(e)
false
......@@ -32,6 +35,10 @@ module Gitlab
attr_accessor :path_to_bundle, :shared
def update_importable_repository_info
# No-op. Overridden in EE
end
def ensure_repository_does_not_exist!
if repository.exists?
shared.logger.info(
......@@ -44,3 +51,5 @@ module Gitlab
end
end
end
Gitlab::ImportExport::RepoRestorer.prepend_if_ee('EE::Gitlab::ImportExport::RepoRestorer')
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