From d84650917ae3eee95fc0aae31ad49fe824fe71d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mica=C3=ABl=20Bergeron?= Date: Tue, 30 Jan 2018 09:21:28 -0500 Subject: remove file after `Upload#destroy` it will also automatically prune empty directories for `FileUploader`-based uploaders. --- app/uploaders/file_uploader.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/uploaders') diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 2310e67cb2e..bde1161dfa8 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -15,6 +15,8 @@ class FileUploader < GitlabUploader storage :file + after :remove, :prune_store_dir + def self.root File.join(options.storage_path, 'uploads') end @@ -140,6 +142,10 @@ class FileUploader < GitlabUploader end end + def prune_store_dir + storage.delete_dir!(store_dir) # only remove when empty + end + def markdown_name (image_or_video? ? File.basename(filename, File.extname(filename)) : filename).gsub("]", "\\]") end -- cgit v1.2.1