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
7efa1408
Commit
7efa1408
authored
Aug 01, 2017
by
Stan Hu
Committed by
Shinya Maeda
Aug 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure artifacts are moved locally within the filesystem to prevent timeouts
Closes #3068
parent
451943c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app/uploaders/object_store_uploader.rb
app/uploaders/object_store_uploader.rb
+21
-0
spec/uploaders/object_store_uploader_spec.rb
spec/uploaders/object_store_uploader_spec.rb
+5
-0
No files found.
app/uploaders/object_store_uploader.rb
View file @
7efa1408
...
...
@@ -110,10 +110,14 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
end
def
move_to_store
return
true
if
object_store
==
LOCAL_STORE
file
.
try
(
:storage
)
==
storage
end
def
move_to_cache
return
true
if
object_store
==
LOCAL_STORE
file
.
try
(
:storage
)
==
cache_storage
end
...
...
@@ -128,6 +132,13 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
file
.
try
(
:exists?
)
end
# Override this if you don't want to save local files by default to the Rails.root directory
def
work_dir
# Default path set by CarrierWave:
# https://github.com/carrierwaveuploader/carrierwave/blob/v1.1.0/lib/carrierwave/uploader/cache.rb#L182
CarrierWave
.
tmp_path
end
private
def
set_default_local_store
(
new_file
)
...
...
@@ -152,4 +163,14 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
def
local_storage
CarrierWave
::
Storage
::
File
.
new
(
self
)
end
# To prevent files in local storage from moving across filesystems, override
# the default implementation:
# http://github.com/carrierwaveuploader/carrierwave/blob/v1.1.0/lib/carrierwave/uploader/cache.rb#L181-L183
def
workfile_path
(
for_file
=
original_filename
)
# To be safe, keep this directory outside of the the cache directory
# because calling CarrierWave.clean_cache_files! will remove any files in
# the cache directory.
File
.
join
(
work_dir
,
@cache_id
,
version_name
.
to_s
,
for_file
)
end
end
spec/uploaders/object_store_uploader_spec.rb
View file @
7efa1408
...
...
@@ -92,6 +92,11 @@ describe ObjectStoreUploader do
it
"uploader is of a described_class"
do
expect
(
uploader
).
to
be_a
(
described_class
)
end
it
'moves files locally'
do
expect
(
uploader
.
move_to_store
).
to
be
(
true
)
expect
(
uploader
.
move_to_cache
).
to
be
(
true
)
end
end
context
'when store is null'
do
...
...
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