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
f55ceb05
Commit
f55ceb05
authored
Feb 23, 2018
by
Micaël Bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the failing specs
parent
fb12eaef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
13 deletions
+23
-13
app/controllers/concerns/uploads_actions.rb
app/controllers/concerns/uploads_actions.rb
+3
-2
app/uploaders/file_uploader.rb
app/uploaders/file_uploader.rb
+18
-9
app/uploaders/namespace_file_uploader.rb
app/uploaders/namespace_file_uploader.rb
+1
-1
app/uploaders/personal_file_uploader.rb
app/uploaders/personal_file_uploader.rb
+1
-1
No files found.
app/controllers/concerns/uploads_actions.rb
View file @
f55ceb05
...
...
@@ -64,8 +64,9 @@ module UploadsActions
def
build_uploader_from_upload
return
nil
unless
params
[
:secret
]
&&
params
[
:filename
]
upload_path
=
uploader_class
.
upload_path
(
params
[
:secret
],
params
[
:filename
])
upload
=
Upload
.
find_by
(
uploader:
uploader_class
.
to_s
,
path:
upload_path
)
upload_paths
=
uploader_class
.
new
(
model
,
secret:
params
[
:secret
])
.
upload_paths
(
params
[
:filename
])
upload
=
Upload
.
find_by
(
uploader:
uploader_class
.
to_s
,
path:
upload_paths
)
upload
&
.
build_uploader
end
...
...
app/uploaders/file_uploader.rb
View file @
f55ceb05
...
...
@@ -32,8 +32,11 @@ class FileUploader < GitlabUploader
)
end
def
self
.
base_dir
(
model
)
model_path_segment
(
model
)
def
self
.
base_dir
(
model
,
store
=
Store
::
LOCAL
)
decorated_model
=
model
decorated_model
=
Storage
::
HashedProject
.
new
(
model
)
if
store
==
Store
::
REMOTE
model_path_segment
(
decorated_model
)
end
# used in migrations and import/exports
...
...
@@ -64,6 +67,13 @@ class FileUploader < GitlabUploader
SecureRandom
.
hex
end
def
upload_paths
(
filename
)
[
File
.
join
(
secret
,
filename
),
File
.
join
(
base_dir
(
Store
::
REMOTE
),
secret
,
filename
)
]
end
attr_accessor
:model
def
initialize
(
model
,
mounted_as
=
nil
,
**
uploader_context
)
...
...
@@ -75,10 +85,8 @@ class FileUploader < GitlabUploader
# enforce the usage of Hashed storage when storing to
# remote store as the FileMover doesn't support OS
def
base_dir
model
=
file_storage?
?
@model
:
Storage
::
HashedProject
.
new
(
@model
)
self
.
class
.
base_dir
(
model
)
def
base_dir
(
store
=
nil
)
self
.
class
.
base_dir
(
@model
,
store
||
object_store
)
end
# we don't need to know the actual path, an uploader instance should be
...
...
@@ -88,7 +96,8 @@ class FileUploader < GitlabUploader
end
def
upload_path
if
file_storage?
# Legacy
if
file_storage?
# Legacy path relative to project.full_path
File
.
join
(
dynamic_segment
,
identifier
)
else
File
.
join
(
store_dir
,
identifier
)
...
...
@@ -97,8 +106,8 @@ class FileUploader < GitlabUploader
def
store_dirs
{
Store
::
LOCAL
=>
local_store_dir
=
File
.
join
(
base_dir
,
dynamic_segment
),
Store
::
REMOTE
=>
local_store_dir
Store
::
LOCAL
=>
File
.
join
(
base_dir
,
dynamic_segment
),
Store
::
REMOTE
=>
File
.
join
(
base_dir
(
ObjectStorage
::
Store
::
REMOTE
),
dynamic_segment
)
}
end
...
...
app/uploaders/namespace_file_uploader.rb
View file @
f55ceb05
...
...
@@ -4,7 +4,7 @@ class NamespaceFileUploader < FileUploader
options
.
storage_path
end
def
self
.
base_dir
(
model
)
def
self
.
base_dir
(
model
,
_store
=
nil
)
File
.
join
(
options
.
base_dir
,
'namespace'
,
model_path_segment
(
model
))
end
...
...
app/uploaders/personal_file_uploader.rb
View file @
f55ceb05
...
...
@@ -4,7 +4,7 @@ class PersonalFileUploader < FileUploader
options
.
storage_path
end
def
self
.
base_dir
(
model
)
def
self
.
base_dir
(
model
,
_store
=
nil
)
File
.
join
(
options
.
base_dir
,
model_path_segment
(
model
))
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