Mercurial > hg > soundsoftware-site
comparison app/controllers/attachments_controller.rb @ 1535:e2c122809c5c live
Update download count only after sending file (if send_file fails, does it throw and avoid this? unsure)
author | Chris Cannam |
---|---|
date | Wed, 11 Feb 2015 16:16:07 +0000 |
parents | c86dacc2ef0a |
children |
comparison
equal
deleted
inserted
replaced
1534:b31caaed9d4d | 1535:e2c122809c5c |
---|---|
50 format.api | 50 format.api |
51 end | 51 end |
52 end | 52 end |
53 | 53 |
54 def download | 54 def download |
55 # cc: formerly this happened only if "@attachment.container.is_a?(Version)" | |
56 # or Project. Not good for us, we want to tally all downloads [by humans] | |
57 if not user_is_search_bot? | |
58 @attachment.increment_download | |
59 end | |
60 | |
61 if stale?(:etag => @attachment.digest) | 55 if stale?(:etag => @attachment.digest) |
62 # images are sent inline | 56 # images are sent inline |
63 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), | 57 send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), |
64 :type => detect_content_type(@attachment), | 58 :type => detect_content_type(@attachment), |
65 :disposition => (@attachment.image? ? 'inline' : 'attachment') | 59 :disposition => (@attachment.image? ? 'inline' : 'attachment') |
60 end | |
61 | |
62 # cc: formerly this happened only if "@attachment.container.is_a?(Version)" | |
63 # or Project. Not good for us, we want to tally all downloads [by humans] | |
64 if not user_is_search_bot? | |
65 @attachment.increment_download | |
66 end | 66 end |
67 end | 67 end |
68 | 68 |
69 def thumbnail | 69 def thumbnail |
70 if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) | 70 if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) |