diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2018-04-13 21:29:01 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2018-06-05 16:20:23 +0200 |
commit | b606636eab1d9beb0331703dfca7399bba111f46 (patch) | |
tree | b94bc1de9928aa1836f30493869f76ec976f4699 /app/controllers/concerns/uploads_actions.rb | |
parent | 96d0b1c67bc1f2a2881298ff898954ba00cd563f (diff) | |
download | gitlab-ce-b606636eab1d9beb0331703dfca7399bba111f46.tar.gz |
simplify uploader versions check
Diffstat (limited to 'app/controllers/concerns/uploads_actions.rb')
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index 98a55a6d82c..170bca8b56f 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -31,17 +31,12 @@ module UploadsActions disposition = uploader.image_or_video? ? 'inline' : 'attachment' - if uploader.filename == params[:filename] - return send_upload(uploader, attachment: uploader.filename, disposition: disposition) - end - - uploader_version = uploader.versions.values.find { |version| version.filename == params[:filename] } + uploaders = [uploader, *uploader.versions.values] + uploader = uploaders.find { |version| version.filename == params[:filename] } - if uploader_version - return send_upload(uploader_version, attachment: uploader_version.filename, disposition: disposition) - end + return render_404 unless uploader - render_404 + send_upload(uploader, attachment: uploader.filename, disposition: disposition) end private |