mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
FIX: Better error handling if a file cannot be sent
If for some reason `Discourse.store.path_for` returns `nil`, the forum would throw an error rather than returning 404. Why would it be `nil`? One cause could be changing the type of file store and having the `url` field no longer be relative.
This commit is contained in:
parent
0d0303e7ea
commit
6f656f6e7d
2 changed files with 13 additions and 1 deletions
|
@ -75,7 +75,11 @@ class UploadsController < ApplicationController
|
|||
}
|
||||
opts[:disposition] = "inline" if params[:inline]
|
||||
opts[:disposition] ||= "attachment" unless FileHelper.is_supported_image?(upload.original_filename)
|
||||
send_file(Discourse.store.path_for(upload), opts)
|
||||
|
||||
file_path = Discourse.store.path_for(upload)
|
||||
return render_404 unless file_path
|
||||
|
||||
send_file(file_path, opts)
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue