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
Léo-Paul Géneau
gitlab-ce
Commits
6a4534b6
Commit
6a4534b6
authored
Oct 31, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Style changes and `hashed_storage?` now receives optional feature
parent
95fa6270
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
26 deletions
+40
-26
app/models/project.rb
app/models/project.rb
+24
-4
app/models/storage/hashed_project.rb
app/models/storage/hashed_project.rb
+0
-13
app/models/storage/legacy_project.rb
app/models/storage/legacy_project.rb
+0
-7
spec/models/project_spec.rb
spec/models/project_spec.rb
+16
-2
No files found.
app/models/project.rb
View file @
6a4534b6
...
...
@@ -26,10 +26,15 @@ class Project < ActiveRecord::Base
NUMBER_OF_PERMITTED_BOARDS
=
1
UNKNOWN_IMPORT_URL
=
'http://unknown.git'
.
freeze
# Hashed Storage versions handle rolling out new storage to project and dependents models
# Hashed Storage versions handle rolling out new storage to project and dependents models:
# nil: legacy
# 1: repository
# 2: attachments
LATEST_STORAGE_VERSION
=
2
HASHED_STORAGE_FEATURES
=
{
repository:
1
,
attachments:
2
}.
freeze
cache_markdown_field
:description
,
pipeline: :description
...
...
@@ -1387,7 +1392,7 @@ class Project < ActiveRecord::Base
if
storage
.
rename_repo
Gitlab
::
AppLogger
.
info
"Project was renamed:
#{
full_path_was
}
->
#{
new_full_path
}
"
rename_repo_notify!
storage
.
after_rename_repo
after_rename_repo
else
Rails
.
logger
.
error
"Repository could not be renamed:
#{
full_path_was
}
->
#{
new_full_path
}
"
...
...
@@ -1397,6 +1402,19 @@ class Project < ActiveRecord::Base
end
end
def
after_rename_repo
path_before_change
=
previous_changes
[
'path'
].
first
# We need to check if project had been rolled out to move resource to hashed storage or not and decide
# if we need execute any take action or no-op.
unless
hashed_storage?
(
:attachments
)
Gitlab
::
UploadsTransfer
.
new
.
rename_project
(
path_before_change
,
self
.
path
,
namespace
.
full_path
)
end
Gitlab
::
PagesTransfer
.
new
.
rename_project
(
path_before_change
,
self
.
path
,
namespace
.
full_path
)
end
def
rename_repo_notify!
send_move_instructions
(
full_path_was
)
expires_full_path_cache
...
...
@@ -1596,8 +1614,10 @@ class Project < ActiveRecord::Base
[
nil
,
0
].
include?
(
self
.
storage_version
)
end
def
hashed_storage?
self
.
storage_version
&&
self
.
storage_version
>=
1
def
hashed_storage?
(
feature
=
:repository
)
raise
ArgumentError
,
"Invalid feature"
unless
HASHED_STORAGE_FEATURES
.
include?
(
feature
)
self
.
storage_version
&&
self
.
storage_version
>=
HASHED_STORAGE_FEATURES
[
feature
]
end
def
renamed?
...
...
app/models/storage/hashed_project.rb
View file @
6a4534b6
...
...
@@ -32,19 +32,6 @@ module Storage
true
end
def
after_rename_repo
path_before_change
=
project
.
previous_changes
[
'path'
].
first
# We need to check if project had been rolled out to move resource to hashed storage or not and decide
# if we need execute any take action or no-op.
unless
project
.
storage_version
>=
2
Gitlab
::
UploadsTransfer
.
new
.
rename_project
(
path_before_change
,
project
.
path
,
project
.
namespace
.
full_path
)
end
Gitlab
::
PagesTransfer
.
new
.
rename_project
(
path_before_change
,
project
.
path
,
project
.
namespace
.
full_path
)
end
private
# Generates the hash for the project path and name on disk
...
...
app/models/storage/legacy_project.rb
View file @
6a4534b6
...
...
@@ -47,12 +47,5 @@ module Storage
false
end
def
after_rename_repo
path_before_change
=
project
.
previous_changes
[
'path'
].
first
Gitlab
::
UploadsTransfer
.
new
.
rename_project
(
path_before_change
,
project
.
path
,
project
.
namespace
.
full_path
)
Gitlab
::
PagesTransfer
.
new
.
rename_project
(
path_before_change
,
project
.
path
,
project
.
namespace
.
full_path
)
end
end
end
spec/models/project_spec.rb
View file @
6a4534b6
...
...
@@ -2630,8 +2630,22 @@ describe Project do
end
describe
'#hashed_storage?'
do
it
'returns true'
do
expect
(
project
.
hashed_storage?
).
to
be_truthy
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
expect
(
project
.
hashed_storage?
(
:attachments
)).
to
be_truthy
end
it
'returns false when not rolled out yet'
do
project
.
storage_version
=
1
expect
(
project
.
hashed_storage?
(
:attachments
)).
to
be_falsey
end
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