summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2018-10-07 20:31:08 +0200
committerJan Provaznik <jprovaznik@gitlab.com>2018-12-06 22:00:19 +0100
commit239fdc78b1ced1861cdcf00b8927963e30ef2095 (patch)
treef5888314cdedf47b21a259d334fc739be0e38d5a /app/workers
parentc3bbad762d418857e3f5b52222f5eedd62663229 (diff)
downloadgitlab-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/workers')
-rw-r--r--app/workers/all_queues.yml1
-rw-r--r--app/workers/delete_stored_files_worker.rb22
2 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/all_queues.yml b/app/workers/all_queues.yml
index 2c55806a286..d9fd395c5ec 100644
--- a/app/workers/all_queues.yml
+++ b/app/workers/all_queues.yml
@@ -134,3 +134,4 @@
- delete_diff_files
- detect_repository_languages
- repository_cleanup
+- delete_stored_files
diff --git a/app/workers/delete_stored_files_worker.rb b/app/workers/delete_stored_files_worker.rb
new file mode 100644
index 00000000000..ff7931849d8
--- /dev/null
+++ b/app/workers/delete_stored_files_worker.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class DeleteStoredFilesWorker
+ include ApplicationWorker
+
+ def perform(class_name, keys)
+ klass = begin
+ class_name.constantize
+ rescue NameError
+ nil
+ end
+
+ unless klass
+ message = "Unknown class '#{class_name}'"
+ logger.error(message)
+ Gitlab::Sentry.track_exception(RuntimeError.new(message))
+ return
+ end
+
+ klass.new(logger: logger).delete_keys(keys)
+ end
+end