Attachment model clean up: fixed some inconsistent indentation and an inaccurate comment (closes patch #903 by Rocco Stanzione).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1321 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4cbe6b626e
commit
6348eeaf8a
|
@ -35,9 +35,9 @@ class Attachment < ActiveRecord::Base
|
|||
errors.add_to_base :too_long if self.filesize > Setting.attachment_max_size.to_i.kilobytes
|
||||
end
|
||||
|
||||
def file=(incomming_file)
|
||||
unless incomming_file.nil?
|
||||
@temp_file = incomming_file
|
||||
def file=(incoming_file)
|
||||
unless incoming_file.nil?
|
||||
@temp_file = incoming_file
|
||||
if @temp_file.size > 0
|
||||
self.filename = sanitize_filename(@temp_file.original_filename)
|
||||
self.disk_filename = DateTime.now.strftime("%y%m%d%H%M%S") + "_" + self.filename
|
||||
|
@ -87,7 +87,7 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def image?
|
||||
self.filename =~ /\.(jpeg|jpg|gif|png)$/i
|
||||
self.filename =~ /\.(jpe?g|gif|png)$/i
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -97,8 +97,7 @@ private
|
|||
# NOTE: File.basename doesn't work right with Windows paths on Unix
|
||||
# INCORRECT: just_filename = File.basename(value.gsub('\\\\', '/'))
|
||||
|
||||
# Finally, replace all non alphanumeric, underscore or periods with underscore
|
||||
# Finally, replace all non alphanumeric, hyphens or periods with underscore
|
||||
@filename = just_filename.gsub(/[^\w\.\-]/,'_')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue