@@ -46,6 +46,8 class Attachment < ActiveRecord::Base | |||
|
46 | 46 | cattr_accessor :storage_path |
|
47 | 47 | @@storage_path = Redmine::Configuration['attachments_storage_path'] || "#{Rails.root}/files" |
|
48 | 48 | |
|
49 | before_save :files_to_final_location | |
|
50 | ||
|
49 | 51 | def validate_max_file_size |
|
50 | 52 | if self.filesize > Setting.attachment_max_size.to_i.kilobytes |
|
51 | 53 | errors.add(:base, :too_long, :count => Setting.attachment_max_size.to_i.kilobytes) |
@@ -73,7 +75,7 class Attachment < ActiveRecord::Base | |||
|
73 | 75 | |
|
74 | 76 | # Copies the temporary file to its final location |
|
75 | 77 | # and computes its MD5 hash |
|
76 | def before_save | |
|
78 | def files_to_final_location | |
|
77 | 79 | if @temp_file && (@temp_file.size > 0) |
|
78 | 80 | logger.info("Saving attachment '#{self.diskfile}' (#{@temp_file.size} bytes)") |
|
79 | 81 | md5 = Digest::MD5.new |
General Comments 0
You need to be logged in to leave comments.
Login now