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
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
......
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