summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Mazetto <brodock@gmail.com>2017-10-31 11:31:57 +0100
committerGabriel Mazetto <brodock@gmail.com>2017-10-31 12:13:48 +0100
commit9c41c7ac1ea2e9085424e3eb1fe9924243affb7c (patch)
tree490cf33bc7fe4caf68e46766174e9ad1c068c58a
parent6a4534b62fad51e5e9da0d132ed64626ffdc2d10 (diff)
downloadgitlab-ce-3674-hashed-storage-attachments.tar.gz
Make `#hashed_storage?` require feature argument3674-hashed-storage-attachments
-rw-r--r--app/models/project.rb9
-rw-r--r--app/services/projects/hashed_storage_migration_service.rb2
-rw-r--r--spec/models/project_spec.rb20
-rw-r--r--spec/services/projects/hashed_storage_migration_service_spec.rb2
4 files changed, 14 insertions, 19 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index a43d1a7f484..cc35ebca6ad 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1614,7 +1614,10 @@ class Project < ActiveRecord::Base
[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 @@ class Project < ActiveRecord::Base
end
def migrate_to_hashed_storage!
- return if hashed_storage?
+ return if hashed_storage?(:repository)
update!(repository_read_only: true)
@@ -1678,7 +1681,7 @@ class Project < ActiveRecord::Base
def storage
@storage ||=
- if hashed_storage?
+ if hashed_storage?(:repository)
Storage::HashedProject.new(self)
else
Storage::LegacyProject.new(self)
diff --git a/app/services/projects/hashed_storage_migration_service.rb b/app/services/projects/hashed_storage_migration_service.rb
index 41259de3a16..f5945f3b87f 100644
--- a/app/services/projects/hashed_storage_migration_service.rb
+++ b/app/services/projects/hashed_storage_migration_service.rb
@@ -10,7 +10,7 @@ module Projects
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?
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index fb5d0f9db9c..5eaff405c0e 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2494,7 +2494,7 @@ describe Project do
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 @@ describe Project do
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
diff --git a/spec/services/projects/hashed_storage_migration_service_spec.rb b/spec/services/projects/hashed_storage_migration_service_spec.rb
index aa1988d29d6..b71b47c59b6 100644
--- a/spec/services/projects/hashed_storage_migration_service_spec.rb
+++ b/spec/services/projects/hashed_storage_migration_service_spec.rb
@@ -23,7 +23,7 @@ describe Projects::HashedStorageMigrationService do
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