Commit 609fc37b authored by Micaël Bergeron's avatar Micaël Bergeron

improvements after the ce-mr

parent 00608acc
......@@ -47,11 +47,12 @@ class GitlabUploader < CarrierWave::Uploader::Base
file.present?
end
# Override this if you don't want to save files by default to the Rails.root directory
def cache_dir
File.join(root, base_dir, 'tmp/cache')
end
def work_dir
# Default path set by CarrierWave:
# https://github.com/carrierwaveuploader/carrierwave/blob/v1.0.0/lib/carrierwave/uploader/cache.rb#L182
CarrierWave.tmp_path
File.join(root, base_dir, 'tmp/work')
end
def filename
......@@ -78,6 +79,6 @@ class GitlabUploader < CarrierWave::Uploader::Base
# 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)
File.join(work_dir, cache_id, version_name.to_s, for_file)
end
end
......@@ -224,18 +224,6 @@ module ObjectStorage
file.present?
end
def cache_dir
File.join(root, base_dir, 'tmp/cache')
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
File.join(root, base_dir, 'tmp/work')
end
def store_dir(store = nil)
store_dirs[store || object_store]
end
......@@ -281,15 +269,5 @@ module ObjectStorage
raise UnknownStoreError
end
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
end
......@@ -5,8 +5,11 @@ describe RecordsUploads do
class RecordsUploadsExampleUploader < GitlabUploader
include RecordsUploads::Concern
storage_options Gitlab.config.uploads
storage :file
def dynamic_segment
'co/fe/ee'
end
end
RecordsUploadsExampleUploader.new(build_stubbed(:user))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment