Adds Etags on attachments.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9963 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e74d4ecf5f
commit
2dbabde7f4
|
@ -52,19 +52,22 @@ class AttachmentsController < ApplicationController
|
||||||
@attachment.increment_download
|
@attachment.increment_download
|
||||||
end
|
end
|
||||||
|
|
||||||
# images are sent inline
|
if stale?(:etag => @attachment.digest)
|
||||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
# images are sent inline
|
||||||
:type => detect_content_type(@attachment),
|
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||||
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
:type => detect_content_type(@attachment),
|
||||||
|
:disposition => (@attachment.image? ? 'inline' : 'attachment')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def thumbnail
|
def thumbnail
|
||||||
if @attachment.thumbnailable? && Setting.thumbnails_enabled? && thumbnail = @attachment.thumbnail
|
if @attachment.thumbnailable? && Setting.thumbnails_enabled? && thumbnail = @attachment.thumbnail
|
||||||
send_file thumbnail,
|
if stale?(:etag => thumbnail)
|
||||||
:filename => filename_for_content_disposition(@attachment.filename),
|
send_file thumbnail,
|
||||||
:type => detect_content_type(@attachment),
|
:filename => filename_for_content_disposition(@attachment.filename),
|
||||||
:disposition => 'inline'
|
:type => detect_content_type(@attachment),
|
||||||
|
:disposition => 'inline'
|
||||||
|
end
|
||||||
else
|
else
|
||||||
# No thumbnail for the attachment or thumbnail could not be created
|
# No thumbnail for the attachment or thumbnail could not be created
|
||||||
render :nothing => true, :status => 404
|
render :nothing => true, :status => 404
|
||||||
|
|
Loading…
Reference in New Issue