]> source.dussan.org Git - redmine.git/commitdiff
Fix that AttachmentsController#show don't close the file after reading.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 3 Apr 2016 11:41:41 +0000 (11:41 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 3 Apr 2016 11:41:41 +0000 (11:41 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15289 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/attachments_controller.rb

index 6113957d4465d01ca4878057f673ddb3f9159bf7..a4aea5cf7f79a60dd779dfa97884079a7dace147 100644 (file)
@@ -28,7 +28,7 @@ class AttachmentsController < ApplicationController
     respond_to do |format|
       format.html {
         if @attachment.is_diff?
-          @diff = File.new(@attachment.diskfile, "rb").read
+          @diff = File.read(@attachment.diskfile, :mode => "rb")
           @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
           @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
           # Save diff type as user preference
@@ -38,7 +38,7 @@ class AttachmentsController < ApplicationController
           end
           render :action => 'diff'
         elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
-          @content = File.new(@attachment.diskfile, "rb").read
+          @content = File.read(@attachment.diskfile, :mode => "rb")
           render :action => 'file'
         else
           download