Commit fd8f2de2 authored by John Cai's avatar John Cai Committed by Mayra Cabrera

Remove add_namespace call for project creation

Since CreateRepository will do a mkdir -p when creating a new
repository, we do not need to call AddNamespace before creating the
repository.
parent b62ddb46
...@@ -27,8 +27,12 @@ module Storage ...@@ -27,8 +27,12 @@ module Storage
"#{base_dir}/#{disk_hash}" if disk_hash "#{base_dir}/#{disk_hash}" if disk_hash
end end
# TODO: remove this method entirely after 12.4 https://gitlab.com/gitlab-org/gitlab/issues/33244
# we no longer need ensure_storage_path_exists to call add_namespace since both creating and moving
# repositories will be preceded by a mkdir -p in gitaly to ensure the parent of the destination directory
# exists.
def ensure_storage_path_exists def ensure_storage_path_exists
gitlab_shell.add_namespace(repository_storage, base_dir) true
end end
def rename_repo(old_full_path: nil, new_full_path: nil) def rename_repo(old_full_path: nil, new_full_path: nil)
......
...@@ -23,10 +23,14 @@ module Storage ...@@ -23,10 +23,14 @@ module Storage
project.full_path project.full_path
end end
# TODO: remove this method entirely after 12.4 https://gitlab.com/gitlab-org/gitlab/issues/33244
# we no longer need ensure_storage_path_exists to call add_namespace since both creating and moving
# repositories will be preceded by a mkdir -p in gitaly to ensure the parent of the destination directory
# exists.
def ensure_storage_path_exists def ensure_storage_path_exists
return unless namespace return unless namespace
gitlab_shell.add_namespace(repository_storage, base_dir) true
end end
def rename_repo(old_full_path: nil, new_full_path: nil) def rename_repo(old_full_path: nil, new_full_path: nil)
......
...@@ -113,10 +113,6 @@ module Gitlab ...@@ -113,10 +113,6 @@ module Gitlab
success success
end end
# Move repository reroutes to mv_directory which is an alias for
# mv_namespace. Given the underlying implementation is a move action,
# indescriminate of what the folders might be.
#
# storage - project's storage path # storage - project's storage path
# path - project disk path # path - project disk path
# new_path - new project disk path # new_path - new project disk path
...@@ -275,7 +271,6 @@ module Gitlab ...@@ -275,7 +271,6 @@ module Gitlab
false false
end end
alias_method :mv_directory, :mv_namespace # Note: ShellWorker uses this alias
def url_to_repo(path) def url_to_repo(path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git" Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
......
...@@ -10,7 +10,6 @@ describe Backup::Repository do ...@@ -10,7 +10,6 @@ describe Backup::Repository do
before do before do
allow(progress).to receive(:puts) allow(progress).to receive(:puts)
allow(progress).to receive(:print) allow(progress).to receive(:print)
allow(FileUtils).to receive(:mkdir_p).and_return(true)
allow(FileUtils).to receive(:mv).and_return(true) allow(FileUtils).to receive(:mv).and_return(true)
allow_any_instance_of(described_class).to receive(:progress).and_return(progress) allow_any_instance_of(described_class).to receive(:progress).and_return(progress)
......
...@@ -3648,14 +3648,6 @@ describe Project do ...@@ -3648,14 +3648,6 @@ describe Project do
end end
end end
describe '#ensure_storage_path_exists' do
it 'delegates to gitlab_shell to ensure namespace is created' do
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, project.base_dir)
project.ensure_storage_path_exists
end
end
describe '#legacy_storage?' do describe '#legacy_storage?' do
it 'returns true when storage_version is nil' do it 'returns true when storage_version is nil' do
project = build(:project, storage_version: nil) project = build(:project, storage_version: nil)
...@@ -3770,16 +3762,6 @@ describe Project do ...@@ -3770,16 +3762,6 @@ describe Project do
end end
end end
describe '#ensure_storage_path_exists' do
it 'delegates to gitlab_shell to ensure namespace is created' do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, hashed_prefix)
project.ensure_storage_path_exists
end
end
describe '#pages_path' do describe '#pages_path' do
it 'returns a path where pages are stored' do it 'returns a path where pages are stored' do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path)) expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
......
...@@ -8,7 +8,7 @@ describe Groups::DestroyService do ...@@ -8,7 +8,7 @@ describe Groups::DestroyService do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let!(:group) { create(:group) } let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) } let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, :legacy_storage, namespace: group) } let!(:project) { create(:project, :repository, :legacy_storage, namespace: group) }
let!(:notification_setting) { create(:notification_setting, source: group)} let!(:notification_setting) { create(:notification_setting, source: group)}
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:remove_path) { group.path + "+#{group.id}+deleted" } let(:remove_path) { group.path + "+#{group.id}+deleted" }
......
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