# HG changeset patch # User Chris Cannam # Date 1423671367 0 # Node ID e2c122809c5c5d28a7895d4c9eb82e4b57808a43 # Parent b31caaed9d4d3b414e063d117ac00f0efd37daff Update download count only after sending file (if send_file fails, does it throw and avoid this? unsure) diff -r b31caaed9d4d -r e2c122809c5c app/controllers/attachments_controller.rb --- a/app/controllers/attachments_controller.rb Wed Feb 11 14:19:20 2015 +0000 +++ b/app/controllers/attachments_controller.rb Wed Feb 11 16:16:07 2015 +0000 @@ -52,18 +52,18 @@ end def download - # cc: formerly this happened only if "@attachment.container.is_a?(Version)" - # or Project. Not good for us, we want to tally all downloads [by humans] - if not user_is_search_bot? - @attachment.increment_download - end - if stale?(:etag => @attachment.digest) # images are sent inline send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), :type => detect_content_type(@attachment), :disposition => (@attachment.image? ? 'inline' : 'attachment') end + + # cc: formerly this happened only if "@attachment.container.is_a?(Version)" + # or Project. Not good for us, we want to tally all downloads [by humans] + if not user_is_search_bot? + @attachment.increment_download + end end def thumbnail