Browse Source

Fix RuboCop offense Lint/NonAtomicFileOperation (#36919).


git-svn-id: https://svn.redmine.org/redmine/trunk@21694 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/5.1.0
Go MAEDA 1 year ago
parent
commit
2cd4996a54
3 changed files with 3 additions and 9 deletions
  1. 1
    3
      app/models/attachment.rb
  2. 1
    3
      lib/redmine/thumbnail.rb
  3. 1
    3
      lib/redmine/utils.rb

+ 1
- 3
app/models/attachment.rb 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

+ 1
- 3
lib/redmine/thumbnail.rb 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

+ 1
- 3
lib/redmine/utils.rb 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 = ""

Loading…
Cancel
Save