copy the mongrel temp file, and chmod 0644. pass :chmod => 0777 to change

git-svn-id: http://svn.techno-weenie.net/projects/plugins/attachment_fu@2720 567b1171-46fb-0310-a4c9-b4bef9110e78
This commit is contained in:
technoweenie 2007-01-29 22:28:35 +00:00
Родитель 7221288404
Коммит bfb2c57e53
2 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -312,16 +312,14 @@ module Technoweenie # :nodoc:
"#{rand Time.now.to_i}#{filename || 'attachment'}"
end
@@filename_basename_regex = /^.*(\\|\/)/
@@filename_character_regex = /[^\w\.\-]/
def sanitize_filename(filename)
returning filename.strip do |name|
# NOTE: File.basename doesn't work right with Windows paths on Unix
# get only the filename, not the whole path
name.gsub! @@filename_basename_regex, ''
name.gsub! /^.*(\\|\/)/, ''
# Finally, replace all non alphanumeric, underscore or periods with underscore
name.gsub! @@filename_character_regex, '_'
name.gsub! /[^\w\.\-]/, '_'
end
end

Просмотреть файл

@ -69,7 +69,8 @@ module Technoweenie # :nodoc:
if save_attachment?
# TODO: This overwrites the file if it exists, maybe have an allow_overwrite option?
FileUtils.mkdir_p(File.dirname(full_filename))
FileUtils.mv temp_path, full_filename
File.cp(temp_path, full_filename)
File.chmod(attachment_options[:chmod] || 0644, full_filename)
end
@old_filename = nil
true