Commit b606636e authored by Alexis Reigel's avatar Alexis Reigel Committed by Alexis Reigel

simplify uploader versions check

parent 96d0b1c6
...@@ -31,17 +31,12 @@ module UploadsActions ...@@ -31,17 +31,12 @@ module UploadsActions
disposition = uploader.image_or_video? ? 'inline' : 'attachment' disposition = uploader.image_or_video? ? 'inline' : 'attachment'
if uploader.filename == params[:filename] uploaders = [uploader, *uploader.versions.values]
return send_upload(uploader, attachment: uploader.filename, disposition: disposition) uploader = uploaders.find { |version| version.filename == params[:filename] }
end
uploader_version = uploader.versions.values.find { |version| version.filename == params[:filename] }
if uploader_version return render_404 unless uploader
return send_upload(uploader_version, attachment: uploader_version.filename, disposition: disposition)
end
render_404 send_upload(uploader, attachment: uploader.filename, disposition: disposition)
end end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment