Fix RuboCop offense Lint/NonAtomicFileOperation (#36919).

git-svn-id: https://svn.redmine.org/redmine/trunk@21694 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2022-06-30 07:35:23 +00:00
parent d4e9663d80
commit 2cd4996a54
3 changed files with 3 additions and 9 deletions

View File

@@ -525,9 +525,7 @@ class Attachment < ActiveRecord::Base
# Physically deletes the file from the file system
def delete_from_disk!
if disk_filename.present? && File.exist?(diskfile)
File.delete(diskfile)
end
FileUtils.rm_f(diskfile) if disk_filename.present?
Dir[thumbnail_path("*")].each do |thumb|
File.delete(thumb)
end

View File

@@ -43,9 +43,7 @@ module Redmine
return nil if is_pdf && mime_type != "application/pdf"
directory = File.dirname(target)
unless File.exist?(directory)
FileUtils.mkdir_p directory
end
FileUtils.mkdir_p directory
size_option = "#{size}x#{size}>"
if is_pdf

View File

@@ -51,9 +51,7 @@ module Redmine
def save_upload(upload, path)
directory = File.dirname(path)
unless File.exist?(directory)
FileUtils.mkdir_p directory
end
FileUtils.mkdir_p directory
File.open(path, "wb") do |f|
if upload.respond_to?(:read)
buffer = ""