changeset 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 b31caaed9d4d
children e2a3230f61fa
files app/controllers/attachments_controller.rb
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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