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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a4d0f3bd
Commit
a4d0f3bd
authored
Jan 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
d796eb27
c23534c5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
26 deletions
+29
-26
app/uploaders/personal_file_uploader.rb
app/uploaders/personal_file_uploader.rb
+9
-9
changelogs/unreleased/sh-fix-snippet-uploads-path-lookup.yml
changelogs/unreleased/sh-fix-snippet-uploads-path-lookup.yml
+5
-0
spec/uploaders/personal_file_uploader_spec.rb
spec/uploaders/personal_file_uploader_spec.rb
+15
-17
No files found.
app/uploaders/personal_file_uploader.rb
View file @
a4d0f3bd
...
...
@@ -6,8 +6,15 @@ class PersonalFileUploader < FileUploader
options
.
storage_path
end
def
self
.
base_dir
(
model
,
_store
=
nil
)
File
.
join
(
options
.
base_dir
,
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
,
model_path_segment
(
model
)),
Store
::
REMOTE
=>
model_path_segment
(
model
)
}
end
def
self
.
model_path_segment
(
model
)
...
...
@@ -33,13 +40,6 @@ class PersonalFileUploader < FileUploader
store_dirs
[
object_store
]
end
def
store_dirs
{
Store
::
LOCAL
=>
File
.
join
(
base_dir
,
dynamic_segment
),
Store
::
REMOTE
=>
File
.
join
(
self
.
class
.
model_path_segment
(
model
),
dynamic_segment
)
}
end
private
def
secure_url
...
...
changelogs/unreleased/sh-fix-snippet-uploads-path-lookup.yml
0 → 100644
View file @
a4d0f3bd
---
title
:
Fix 404s with snippet uploads in object storage
merge_request
:
24550
author
:
type
:
fixed
spec/uploaders/personal_file_uploader_spec.rb
View file @
a4d0f3bd
...
...
@@ -4,19 +4,13 @@ describe PersonalFileUploader do
let
(
:model
)
{
create
(
:personal_snippet
)
}
let
(
:uploader
)
{
described_class
.
new
(
model
)
}
let
(
:upload
)
{
create
(
:upload
,
:personal_snippet_upload
)
}
let
(
:identifier
)
{
%r{
\h
+/
\S
+}
}
subject
{
uploader
}
it_behaves_like
'builds correct paths'
do
let
(
:patterns
)
do
{
it_behaves_like
'builds correct paths'
,
store_dir:
%r[uploads/-/system/personal_snippet/
\d
+]
,
upload_path:
identifier
,
absolute_path:
%r[
#{
CarrierWave
.
root
}
/uploads/-/system/personal_snippet/
\d
+/
#{
identifier
}
]
}
end
end
upload_path:
%r[
\h
+/
\S
+]
,
absolute_path:
%r[
#{
CarrierWave
.
root
}
/uploads/-/system/personal_snippet
\/\d
+
\/\h
+
\/\S
+$]
context
"object_store is REMOTE"
do
before
do
...
...
@@ -25,13 +19,17 @@ describe PersonalFileUploader do
include_context
'with storage'
,
described_class
::
Store
::
REMOTE
it_behaves_like
'builds correct paths'
do
let
(
:patterns
)
do
{
it_behaves_like
'builds correct paths'
,
store_dir:
%r[
\d
+/
\h
+]
,
upload_path:
identifier
}
upload_path:
%r[^personal_snippet
\/\d
+
\/\h
+
\/
<filename>]
end
describe
'#upload_paths'
do
it
'builds correct paths for both local and remote storage'
do
paths
=
uploader
.
upload_paths
(
'test.jpg'
)
expect
(
paths
.
first
).
to
match
(
%r[
\h
+
\/
test.jpg]
)
expect
(
paths
.
second
).
to
match
(
%r[^personal_snippet
\/\d
+
\/\h
+
\/
test.jpg]
)
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