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 9c41c7ac authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Make `#hashed_storage?` require feature argument

parent 4d0e5a197f8e
......@@ -1614,7 +1614,10 @@ def legacy_storage?
[nil, 0].include?(self.storage_version)
end
def hashed_storage?(feature=:repository)
# Check if Hashed Storage is enabled for the project with at least informed feature rolled out
#
# @param [Symbol] feature that needs to be rolled out for the project (:repository, :attachments)
def hashed_storage?(feature)
raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
......@@ -1653,7 +1656,7 @@ def ff_merge_must_be_possible?
end
def migrate_to_hashed_storage!
return if hashed_storage?
return if hashed_storage?(:repository)
update!(repository_read_only: true)
......@@ -1678,7 +1681,7 @@ def gl_repository(is_wiki:)
def storage
@storage ||=
if hashed_storage?
if hashed_storage?(:repository)
Storage::HashedProject.new(self)
else
Storage::LegacyProject.new(self)
......
......@@ -10,7 +10,7 @@ def initialize(project, logger = nil)
end
def execute
return if project.hashed_storage?
return if project.hashed_storage?(:repository)
@old_disk_path = project.disk_path
has_wiki = project.wiki.repository_exists?
......
......@@ -2494,7 +2494,7 @@ def enable_lfs
describe '#hashed_storage?' do
it 'returns false' do
expect(project.hashed_storage?).to be_falsey
expect(project.hashed_storage?(:repository)).to be_falsey
end
end
......@@ -2630,22 +2630,14 @@ def enable_lfs
end
describe '#hashed_storage?' do
context 'without specifying feature' do
it 'returns true' do
expect(project.hashed_storage?).to be_truthy
end
it 'returns true if rolled out' do
expect(project.hashed_storage?(:attachments)).to be_truthy
end
context 'specifying feature' do
it 'returns true if rolled out' do
expect(project.hashed_storage?(:attachments)).to be_truthy
end
it 'returns false when not rolled out yet' do
project.storage_version = 1
it 'returns false when not rolled out yet' do
project.storage_version = 1
expect(project.hashed_storage?(:attachments)).to be_falsey
end
expect(project.hashed_storage?(:attachments)).to be_falsey
end
end
......
......@@ -23,7 +23,7 @@
it 'updates project to be hashed and not read-only' do
service.execute
expect(project.hashed_storage?).to be_truthy
expect(project.hashed_storage?(:repository)).to be_truthy
expect(project.repository_read_only).to be_falsey
end
......
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