Defect #33752 » file_size.diff
app/models/attachment.rb (working copy) | ||
---|---|---|
95 | 95 |
if @temp_file.respond_to?(:content_type) |
96 | 96 |
self.content_type = @temp_file.content_type.to_s.chomp |
97 | 97 |
end |
98 |
self.filesize = @temp_file.size |
|
99 | 98 |
end |
100 | 99 |
end |
101 | 100 | |
... | ... | |
114 | 113 |
if @temp_file |
115 | 114 |
self.disk_directory = target_directory |
116 | 115 |
self.disk_filename = Attachment.disk_filename(filename, disk_directory) |
117 |
logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)") if logger
|
|
116 |
logger.info("Saving attachment '#{self.diskfile}'") if logger |
|
118 | 117 |
path = File.dirname(diskfile) |
119 | 118 |
unless File.directory?(path) |
120 | 119 |
FileUtils.mkdir_p(path) |
121 | 120 |
end |
122 | 121 |
sha = Digest::SHA256.new |
122 |
self.filesize = 0 |
|
123 | 123 |
File.open(diskfile, "wb") do |f| |
124 | 124 |
if @temp_file.respond_to?(:read) |
125 | 125 |
buffer = "" |
... | ... | |
131 | 131 |
f.write(@temp_file) |
132 | 132 |
sha.update(@temp_file) |
133 | 133 |
end |
134 |
self.filesize = f.size |
|
134 | 135 |
end |
135 | 136 |
self.digest = sha.hexdigest |
136 | 137 |
end |