mirror of
https://github.com/meineerde/redmine.git
synced 2025-10-17 17:01:01 +00:00
code cleanup: rubocop: fix Lint/IneffectiveAccessModifier in app/models/attachment.rb
git-svn-id: http://svn.redmine.org/redmine/trunk@18781 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
75d3e4037b
commit
d836d9cc69
@ -390,7 +390,6 @@ Lint/HandleExceptions:
|
|||||||
|
|
||||||
Lint/IneffectiveAccessModifier:
|
Lint/IneffectiveAccessModifier:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'app/models/attachment.rb'
|
|
||||||
- 'app/models/mail_handler.rb'
|
- 'app/models/mail_handler.rb'
|
||||||
|
|
||||||
Lint/InterpolationCheck:
|
Lint/InterpolationCheck:
|
||||||
|
|||||||
@ -492,21 +492,24 @@ class Attachment < ActiveRecord::Base
|
|||||||
time.strftime("%Y/%m")
|
time.strftime("%Y/%m")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an ASCII or hashed filename that do not
|
# Singleton class method is public
|
||||||
# exists yet in the given subdirectory
|
class << self
|
||||||
def self.disk_filename(filename, directory=nil)
|
# Returns an ASCII or hashed filename that do not
|
||||||
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
# exists yet in the given subdirectory
|
||||||
ascii = ''
|
def disk_filename(filename, directory=nil)
|
||||||
if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
|
timestamp = DateTime.now.strftime("%y%m%d%H%M%S")
|
||||||
ascii = filename
|
ascii = ''
|
||||||
else
|
if %r{^[a-zA-Z0-9_\.\-]*$}.match?(filename) && filename.length <= 50
|
||||||
ascii = Digest::MD5.hexdigest(filename)
|
ascii = filename
|
||||||
# keep the extension if any
|
else
|
||||||
ascii << $1 if filename =~ %r{(\.[a-zA-Z0-9]+)$}
|
ascii = Digest::MD5.hexdigest(filename)
|
||||||
|
# keep the extension if any
|
||||||
|
ascii << $1 if filename =~ %r{(\.[a-zA-Z0-9]+)$}
|
||||||
|
end
|
||||||
|
while File.exist?(File.join(storage_path, directory.to_s, "#{timestamp}_#{ascii}"))
|
||||||
|
timestamp.succ!
|
||||||
|
end
|
||||||
|
"#{timestamp}_#{ascii}"
|
||||||
end
|
end
|
||||||
while File.exist?(File.join(storage_path, directory.to_s, "#{timestamp}_#{ascii}"))
|
|
||||||
timestamp.succ!
|
|
||||||
end
|
|
||||||
"#{timestamp}_#{ascii}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user