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/workers | |
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/workers')
-rw-r--r-- | app/workers/all_queues.yml | 1 | ||||
-rw-r--r-- | app/workers/delete_stored_files_worker.rb | 22 |
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 |