debian-mirror-gitlab/app/uploaders/lfs_object_uploader.rb

32 lines
879 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
class LfsObjectUploader < GitlabUploader
2015-11-26 14:37:03 +05:30
storage :file
def store_dir
2016-08-24 12:49:21 +05:30
"#{Gitlab.config.lfs.storage_path}/#{model.oid[0, 2]}/#{model.oid[2, 2]}"
2015-11-26 14:37:03 +05:30
end
def cache_dir
"#{Gitlab.config.lfs.storage_path}/tmp/cache"
end
2017-08-17 22:00:37 +05:30
def filename
model.oid[4..-1]
2015-11-26 14:37:03 +05:30
end
2017-08-17 22:00:37 +05:30
def work_dir
File.join(Gitlab.config.lfs.storage_path, 'tmp', 'work')
2015-11-26 14:37:03 +05:30
end
2017-08-17 22:00:37 +05:30
private
2015-11-26 14:37:03 +05:30
2017-08-17 22:00:37 +05:30
# To prevent LFS files from moving across filesystems, override the default
# implementation:
# http://github.com/carrierwaveuploader/carrierwave/blob/v1.0.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)
2015-11-26 14:37:03 +05:30
end
end