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
0a1c805d
Commit
0a1c805d
authored
Aug 20, 2018
by
Jarka Kadlecová
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NamespaceUploader.base_dir for remote uploads
parent
3c80adf5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
9 deletions
+28
-9
app/uploaders/namespace_file_uploader.rb
app/uploaders/namespace_file_uploader.rb
+9
-9
changelogs/unreleased/fix-namespace-uploader.yml
changelogs/unreleased/fix-namespace-uploader.yml
+5
-0
spec/uploaders/namespace_file_uploader_spec.rb
spec/uploaders/namespace_file_uploader_spec.rb
+14
-0
No files found.
app/uploaders/namespace_file_uploader.rb
View file @
0a1c805d
...
...
@@ -6,8 +6,15 @@ class NamespaceFileUploader < FileUploader
options
.
storage_path
end
def
self
.
base_dir
(
model
,
_store
=
nil
)
File
.
join
(
options
.
base_dir
,
'namespace'
,
model_path_segment
(
model
))
def
self
.
base_dir
(
model
,
store
=
nil
)
base_dirs
(
model
)[
store
||
Store
::
LOCAL
]
end
def
self
.
base_dirs
(
model
)
{
Store
::
LOCAL
=>
File
.
join
(
options
.
base_dir
,
'namespace'
,
model_path_segment
(
model
)),
Store
::
REMOTE
=>
File
.
join
(
'namespace'
,
model_path_segment
(
model
))
}
end
def
self
.
model_path_segment
(
model
)
...
...
@@ -18,11 +25,4 @@ class NamespaceFileUploader < FileUploader
def
store_dir
store_dirs
[
object_store
]
end
def
store_dirs
{
Store
::
LOCAL
=>
File
.
join
(
base_dir
,
dynamic_segment
),
Store
::
REMOTE
=>
File
.
join
(
'namespace'
,
self
.
class
.
model_path_segment
(
model
),
dynamic_segment
)
}
end
end
changelogs/unreleased/fix-namespace-uploader.yml
0 → 100644
View file @
0a1c805d
---
title
:
Fix NamespaceUploader.base_dir for remote uploads
merge_request
:
author
:
type
:
fixed
spec/uploaders/namespace_file_uploader_spec.rb
View file @
0a1c805d
...
...
@@ -26,6 +26,20 @@ describe NamespaceFileUploader do
upload_path:
IDENTIFIER
end
context
'.base_dir'
do
it
'returns local storage base_dir without store param'
do
expect
(
described_class
.
base_dir
(
group
)).
to
eq
(
"uploads/-/system/namespace/
#{
group
.
id
}
"
)
end
it
'returns local storage base_dir when store param is Store::LOCAL'
do
expect
(
described_class
.
base_dir
(
group
,
ObjectStorage
::
Store
::
LOCAL
)).
to
eq
(
"uploads/-/system/namespace/
#{
group
.
id
}
"
)
end
it
'returns remote base_dir when store param is Store::REMOTE'
do
expect
(
described_class
.
base_dir
(
group
,
ObjectStorage
::
Store
::
REMOTE
)).
to
eq
(
"namespace/
#{
group
.
id
}
"
)
end
end
describe
"#migrate!"
do
before
do
uploader
.
store!
(
fixture_file_upload
(
File
.
join
(
'spec/fixtures/doc_sample.txt'
)))
...
...
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