#1738 修复图片下载次数不正确问题

dev_repository_hjq
guange 11 years ago
parent c893a2d99b
commit 5d1a5a0b11

@ -25,8 +25,10 @@ gem 'rufus-scheduler'
#gem 'dalli', path: 'lib/dalli-2.7.2' #gem 'dalli', path: 'lib/dalli-2.7.2'
group :development do group :development do
gem 'grape-swagger' gem 'grape-swagger'
gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git' #gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
#gem 'puma' #gem 'puma'
gem 'pry-rails'
gem 'pry-byebug'
gem 'better_errors', path: 'lib/better_errors' gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
end end
@ -50,8 +52,8 @@ group :test do
#end #end
end end
gem 'rspec-rails' , '2.13.1' # gem 'rspec-rails' , '2.13.1'
gem 'guard-rspec','2.5.0' # gem 'guard-rspec','2.5.0'
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
group :assets do group :assets do
@ -95,7 +97,7 @@ if File.exist?(database_file)
adapters.each do |adapter| adapters.each do |adapter|
case adapter case adapter
when 'mysql2' when 'mysql2'
gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw] gem "mysql2", "= 0.3.18", :platforms => [:mri, :mingw]
gem "activerecord-jdbcmysql-adapter", :platforms => :jruby gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
when 'mysql' when 'mysql'
gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw] gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw]

@ -97,12 +97,10 @@ class AttachmentsController < ApplicationController
end end
if candown || User.current.admin? || User.current.id == @attachment.author_id if candown || User.current.admin? || User.current.id == @attachment.author_id
@attachment.increment_download @attachment.increment_download
if stale?(:etag => @attachment.digest) if stale?(:etag => @attachment.digest)
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment), :type => detect_content_type(@attachment),
:disposition => (@attachment.image? ? 'inline' : 'attachment') :disposition => 'attachment' #inline can open in browser
end end
else else

Loading…
Cancel
Save