diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-06 18:19:35 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-02-06 18:19:35 +0300 |
commit | 9ab4c5b735e0e121996b092cb20bcdc423045c5e (patch) | |
tree | 981ea32cf01d5261e9956439ce9745c5e2ae6dcf /app/uploaders | |
parent | 86342966a1b61d30dca019e983235aadc14a36ef (diff) | |
parent | 939391af7bc471f1588ab75ab0cf08d8e4286a05 (diff) |
Merge branch '14256-upload-destroy-removes-file' into 'master'
Uploads should delete files when destroyed
Closes #14256
See merge request gitlab-org/gitlab-ce!16799
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/file_uploader.rb | 6 |
1 files changed, 6 insertions, 0 deletions
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 |