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
Jérome Perrin
gitlab-ce
Commits
02737b85
Commit
02737b85
authored
Aug 17, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `@hashed` prefix for hashed paths on disk, to avoid collision with existing ones
parent
d17a7be8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
app/models/storage/hashed_project.rb
app/models/storage/hashed_project.rb
+4
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+3
-3
No files found.
app/models/storage/hashed_project.rb
View file @
02737b85
module
Storage
module
Storage
class
HashedProject
class
HashedProject
attr_accessor
:project
attr_accessor
:project
delegate
:namespace
,
:gitlab_shell
,
:repository_storage_path
,
to: :project
delegate
:gitlab_shell
,
:repository_storage_path
,
to: :project
ROOT_PATH_PREFIX
=
'@hashed'
.
freeze
def
initialize
(
project
)
def
initialize
(
project
)
@project
=
project
@project
=
project
...
@@ -11,7 +13,7 @@ module Storage
...
@@ -11,7 +13,7 @@ module Storage
#
#
# @return [String] directory where repository is stored
# @return [String] directory where repository is stored
def
base_dir
def
base_dir
"
#{
disk_hash
[
0
..
1
]
}
/
#{
disk_hash
[
2
..
3
]
}
"
if
disk_hash
"
#{
ROOT_PATH_PREFIX
}
/
#{
disk_hash
[
0
..
1
]
}
/
#{
disk_hash
[
2
..
3
]
}
"
if
disk_hash
end
end
# Disk path is used to build repository and project's wiki path on disk
# Disk path is used to build repository and project's wiki path on disk
...
...
spec/models/project_spec.rb
View file @
02737b85
...
@@ -2413,13 +2413,13 @@ describe Project do
...
@@ -2413,13 +2413,13 @@ describe Project do
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
expect
(
project
.
base_dir
).
to
eq
(
'6b/86'
)
expect
(
project
.
base_dir
).
to
eq
(
'
@hashed/
6b/86'
)
end
end
end
end
describe
'#disk_path'
do
describe
'#disk_path'
do
it
'returns disk_path based on hash of project id'
do
it
'returns disk_path based on hash of project id'
do
hashed_path
=
'6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
hashed_path
=
'
@hashed/
6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b'
expect
(
project
.
disk_path
).
to
eq
(
hashed_path
)
expect
(
project
.
disk_path
).
to
eq
(
hashed_path
)
end
end
...
@@ -2427,7 +2427,7 @@ describe Project do
...
@@ -2427,7 +2427,7 @@ describe Project do
describe
'#ensure_storage_path_exists'
do
describe
'#ensure_storage_path_exists'
do
it
'delegates to gitlab_shell to ensure namespace is created'
do
it
'delegates to gitlab_shell to ensure namespace is created'
do
expect
(
gitlab_shell
).
to
receive
(
:add_namespace
).
with
(
project
.
repository_storage_path
,
'6b/86'
)
expect
(
gitlab_shell
).
to
receive
(
:add_namespace
).
with
(
project
.
repository_storage_path
,
'
@hashed/
6b/86'
)
project
.
ensure_storage_path_exists
project
.
ensure_storage_path_exists
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