mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: Fix methods removed in Ruby 3.2 (#15459)
* File.exists? is deprecated and removed in Ruby 3.2 in favor of File.exist? * Dir.exists? is deprecated and removed in Ruby 3.2 in favor of Dir.exist?
This commit is contained in:
@ -14,11 +14,11 @@ module FileStore
|
||||
def remove_file(url, _)
|
||||
return unless is_relative?(url)
|
||||
source = "#{public_dir}#{url}"
|
||||
return unless File.exists?(source)
|
||||
return unless File.exist?(source)
|
||||
destination = "#{public_dir}#{url.sub("/uploads/", "/uploads/tombstone/")}"
|
||||
dir = Pathname.new(destination).dirname
|
||||
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
|
||||
FileUtils.remove(destination) if File.exists?(destination)
|
||||
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
||||
FileUtils.remove(destination) if File.exist?(destination)
|
||||
FileUtils.move(source, destination, force: true)
|
||||
FileUtils.touch(destination)
|
||||
end
|
||||
@ -62,7 +62,7 @@ module FileStore
|
||||
end
|
||||
|
||||
def purge_tombstone(grace_period)
|
||||
if Dir.exists?(Discourse.store.tombstone_dir)
|
||||
if Dir.exist?(Discourse.store.tombstone_dir)
|
||||
Discourse::Utils.execute_command(
|
||||
'find', tombstone_dir, '-mtime', "+#{grace_period}", '-type', 'f', '-delete'
|
||||
)
|
||||
@ -75,7 +75,7 @@ module FileStore
|
||||
|
||||
def copy_file(file, path)
|
||||
dir = Pathname.new(path).dirname
|
||||
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
|
||||
FileUtils.mkdir_p(dir) unless Dir.exist?(dir)
|
||||
# move the file to the right location
|
||||
# not using mv, cause permissions are no good on move
|
||||
File.open(path, "wb") { |f| f.write(file.read) }
|
||||
|
Reference in New Issue
Block a user