Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
19 deletions
+14
-19
app/models/project.rb
app/models/project.rb
+6
-3
app/services/projects/hashed_storage_migration_service.rb
app/services/projects/hashed_storage_migration_service.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-14
spec/services/projects/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
...
@@ -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
)
...
...
app/services/projects/hashed_storage_migration_service.rb
View file @
9c41c7ac
...
@@ -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?
...
...
spec/models/project_spec.rb
View file @
9c41c7ac
...
@@ -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
...
...
spec/services/projects/hashed_storage_migration_service_spec.rb
View file @
9c41c7ac
...
@@ -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
...
...
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