diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-10-07 20:31:08 +0200 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-12-06 22:00:19 +0100 |
commit | 239fdc78b1ced1861cdcf00b8927963e30ef2095 (patch) | |
tree | f5888314cdedf47b21a259d334fc739be0e38d5a /app/models/upload.rb | |
parent | c3bbad762d418857e3f5b52222f5eedd62663229 (diff) | |
download | gitlab-ce-239fdc78b1ced1861cdcf00b8927963e30ef2095.tar.gz |
Use FastDestroy for deleting uploads
It gathers list of file paths to delete before destroying
the parent object. Then after the parent_object is destroyed
these paths are scheduled for deletion asynchronously.
Carrierwave needed associated model for deleting upload file.
To avoid this requirement, simple Fog/File layer is used directly
for file deletion, this allows us to use just a simple list of paths.
Diffstat (limited to 'app/models/upload.rb')
-rw-r--r-- | app/models/upload.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/upload.rb b/app/models/upload.rb index e01e9c6a4f0..20860f14b83 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -25,6 +25,25 @@ class Upload < ActiveRecord::Base Digest::SHA256.file(path).hexdigest end + class << self + ## + # FastDestroyAll concerns + def begin_fast_destroy + { + Uploads::Local => Uploads::Local.new.keys(with_files_stored_locally), + Uploads::Fog => Uploads::Fog.new.keys(with_files_stored_remotely) + } + end + + ## + # FastDestroyAll concerns + def finalize_fast_destroy(keys) + keys.each do |store_class, paths| + store_class.new.delete_keys_async(paths) + end + end + end + def absolute_path raise ObjectStorage::RemoteStoreError, "Remote object has no absolute path." unless local? return path unless relative_path? |