From bc50d5f469e8456d4a6c567ed4b2fa7cf5a36509 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 18 Jul 2014 14:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=B8=8A=E4=BC=A0=E7=A9=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b301ba73c..85f36fc5f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -227,7 +227,8 @@ class Attachment < ActiveRecord::Base def file=(incoming_file) unless incoming_file.nil? @temp_file = incoming_file - if @temp_file.size > 0 + # 允许上传文件大小为0的文件 + #if @temp_file.size > 0 if @temp_file.respond_to?(:original_filename) self.filename = @temp_file.original_filename self.filename.force_encoding("UTF-8") if filename.respond_to?(:force_encoding) @@ -239,7 +240,7 @@ class Attachment < ActiveRecord::Base self.content_type = Redmine::MimeType.of(filename) end self.filesize = @temp_file.size - end + #end end end @@ -255,7 +256,8 @@ class Attachment < ActiveRecord::Base # Copies the temporary file to its final location # and computes its MD5 hash def files_to_final_location - if @temp_file && (@temp_file.size > 0) + # # 允许上传文件大小为0的文件 + if @temp_file# && (@temp_file.size > 0) self.disk_directory = target_directory self.disk_filename = Attachment.disk_filename(filename, disk_directory) logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")