BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
9c41c7ac
Commit
9c41c7ac
authored
Oct 31, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `#hashed_storage?` require feature argument
parent
6a4534b6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
19 deletions
+14
-19
project.rb
app/models/project.rb
+6
-3
hashed_storage_migration_service.rb
app/services/projects/hashed_storage_migration_service.rb
+1
-1
project_spec.rb
spec/models/project_spec.rb
+6
-14
hashed_storage_migration_service_spec.rb
...ervices/projects/hashed_storage_migration_service_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
9c41c7ac
...
...
@@ -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
)
...
...
app/services/projects/hashed_storage_migration_service.rb
View file @
9c41c7ac
...
...
@@ -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?
...
...
spec/models/project_spec.rb
View file @
9c41c7ac
...
...
@@ -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
...
...
spec/services/projects/hashed_storage_migration_service_spec.rb
View file @
9c41c7ac
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment