Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.0 on 2022-01-18 at 14:00 UTC+1 (a few minutes of down time)

Commit 94c5bc31 authored by Douwe Maan's avatar Douwe Maan Committed by Oswaldo Ferreira
Browse files

Merge branch 'bvl-dont-move-projects-using-hashed-storage' into 'master'

Don't move project repository/attachments when using hashed storage

Closes #40289

See merge request gitlab-org/gitlab-ce!15479

(cherry picked from commit bd026b6a28ac410ad455b7b915cafc9782296b6b)

fa39e8a0 Don't move project repository/attachments when using hashed storage
parent b7b3245a6150
---
title: Don't move repositories and attachments for projects using hashed storage
merge_request: 15479
author:
type: other
......@@ -68,6 +68,11 @@ class Project < ActiveRecord::Base
has_one :route, as: :source
self.table_name = 'projects'
HASHED_STORAGE_FEATURES = {
repository: 1,
attachments: 2
}.freeze
def repository_storage_path
Gitlab.config.repositories.storages[repository_storage]['path']
end
......@@ -76,6 +81,13 @@ def repository_storage_path
def self.name
'Project'
end
def hashed_storage?(feature)
raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
return false unless respond_to?(:storage_version)
self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
end
end
end
end
......
......@@ -22,9 +22,11 @@ def rename_project(project)
end
def move_project_folders(project, old_full_path, new_full_path)
move_repository(project, old_full_path, new_full_path)
move_repository(project, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
move_uploads(old_full_path, new_full_path)
unless project.hashed_storage?(:repository)
move_repository(project, old_full_path, new_full_path)
move_repository(project, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
end
move_uploads(old_full_path, new_full_path) unless project.hashed_storage?(:attachments)
move_pages(old_full_path, new_full_path)
end
......
......@@ -87,6 +87,14 @@
subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
end
it 'does not move the repositories when hashed storage is enabled' do
project.update!(storage_version: Project::HASHED_STORAGE_FEATURES[:repository])
expect(subject).not_to receive(:move_repository)
subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
end
it 'moves uploads' do
expect(subject).to receive(:move_uploads)
.with('known-parent/the-path', 'known-parent/the-path0')
......@@ -94,6 +102,14 @@
subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
end
it 'does not move uploads when hashed storage is enabled for attachments' do
project.update!(storage_version: Project::HASHED_STORAGE_FEATURES[:attachments])
expect(subject).not_to receive(:move_uploads)
subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
end
it 'moves pages' do
expect(subject).to receive(:move_pages)
.with('known-parent/the-path', 'known-parent/the-path0')
......
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