Commit 9c41c7ac authored by Gabriel Mazetto's avatar Gabriel Mazetto

Make `#hashed_storage?` require feature argument

parent 6a4534b6
...@@ -1614,7 +1614,10 @@ class Project < ActiveRecord::Base ...@@ -1614,7 +1614,10 @@ class Project < ActiveRecord::Base
[nil, 0].include?(self.storage_version) [nil, 0].include?(self.storage_version)
end 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) raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature] self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
...@@ -1653,7 +1656,7 @@ class Project < ActiveRecord::Base ...@@ -1653,7 +1656,7 @@ class Project < ActiveRecord::Base
end end
def migrate_to_hashed_storage! def migrate_to_hashed_storage!
return if hashed_storage? return if hashed_storage?(:repository)
update!(repository_read_only: true) update!(repository_read_only: true)
...@@ -1678,7 +1681,7 @@ class Project < ActiveRecord::Base ...@@ -1678,7 +1681,7 @@ class Project < ActiveRecord::Base
def storage def storage
@storage ||= @storage ||=
if hashed_storage? if hashed_storage?(:repository)
Storage::HashedProject.new(self) Storage::HashedProject.new(self)
else else
Storage::LegacyProject.new(self) Storage::LegacyProject.new(self)
......
...@@ -10,7 +10,7 @@ module Projects ...@@ -10,7 +10,7 @@ module Projects
end end
def execute def execute
return if project.hashed_storage? return if project.hashed_storage?(:repository)
@old_disk_path = project.disk_path @old_disk_path = project.disk_path
has_wiki = project.wiki.repository_exists? has_wiki = project.wiki.repository_exists?
......
...@@ -2494,7 +2494,7 @@ describe Project do ...@@ -2494,7 +2494,7 @@ describe Project do
describe '#hashed_storage?' do describe '#hashed_storage?' do
it 'returns false' do it 'returns false' do
expect(project.hashed_storage?).to be_falsey expect(project.hashed_storage?(:repository)).to be_falsey
end end
end end
...@@ -2630,13 +2630,6 @@ describe Project do ...@@ -2630,13 +2630,6 @@ describe Project do
end end
describe '#hashed_storage?' do describe '#hashed_storage?' do
context 'without specifying feature' do
it 'returns true' do
expect(project.hashed_storage?).to be_truthy
end
end
context 'specifying feature' do
it 'returns true if rolled out' do it 'returns true if rolled out' do
expect(project.hashed_storage?(:attachments)).to be_truthy expect(project.hashed_storage?(:attachments)).to be_truthy
end end
...@@ -2647,7 +2640,6 @@ describe Project do ...@@ -2647,7 +2640,6 @@ describe Project do
expect(project.hashed_storage?(:attachments)).to be_falsey expect(project.hashed_storage?(:attachments)).to be_falsey
end end
end end
end
describe '#base_dir' do describe '#base_dir' do
it 'returns base_dir based on hash of project id' do it 'returns base_dir based on hash of project id' do
......
...@@ -23,7 +23,7 @@ describe Projects::HashedStorageMigrationService do ...@@ -23,7 +23,7 @@ describe Projects::HashedStorageMigrationService do
it 'updates project to be hashed and not read-only' do it 'updates project to be hashed and not read-only' do
service.execute 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 expect(project.repository_read_only).to be_falsey
end 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