Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
0f3c2ff558
|
@ -227,7 +227,8 @@ class Attachment < ActiveRecord::Base
|
||||||
def file=(incoming_file)
|
def file=(incoming_file)
|
||||||
unless incoming_file.nil?
|
unless incoming_file.nil?
|
||||||
@temp_file = incoming_file
|
@temp_file = incoming_file
|
||||||
if @temp_file.size > 0
|
# 允许上传文件大小为0的文件
|
||||||
|
#if @temp_file.size > 0
|
||||||
if @temp_file.respond_to?(:original_filename)
|
if @temp_file.respond_to?(:original_filename)
|
||||||
self.filename = @temp_file.original_filename
|
self.filename = @temp_file.original_filename
|
||||||
self.filename.force_encoding("UTF-8") if filename.respond_to?(:force_encoding)
|
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)
|
self.content_type = Redmine::MimeType.of(filename)
|
||||||
end
|
end
|
||||||
self.filesize = @temp_file.size
|
self.filesize = @temp_file.size
|
||||||
end
|
#end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -255,7 +256,8 @@ class Attachment < ActiveRecord::Base
|
||||||
# Copies the temporary file to its final location
|
# Copies the temporary file to its final location
|
||||||
# and computes its MD5 hash
|
# and computes its MD5 hash
|
||||||
def files_to_final_location
|
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_directory = target_directory
|
||||||
self.disk_filename = Attachment.disk_filename(filename, disk_directory)
|
self.disk_filename = Attachment.disk_filename(filename, disk_directory)
|
||||||
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)")
|
||||||
|
|
Loading…
Reference in New Issue