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:
Peter Zhu
2022-01-05 12:45:08 -05:00
committed by GitHub
parent 692ba188bf
commit c5fd8c42db
75 changed files with 140 additions and 140 deletions

View File

@ -359,7 +359,7 @@ class BulkImport::DiscourseMerger < BulkImport::Base
next if row['user_id'].nil?
end
row['url'] = "/uploads/default/#{rel_filename}" if File.exists?(absolute_filename)
row['url'] = "/uploads/default/#{rel_filename}" if File.exist?(absolute_filename)
@raw_connection.put_copy_data(row.values)
end

View File

@ -203,7 +203,7 @@ class BulkImport::Vanilla < BulkImport::Base
end
def import_avatars
if ATTACHMENTS_BASE_DIR && File.exists?(ATTACHMENTS_BASE_DIR)
if ATTACHMENTS_BASE_DIR && File.exist?(ATTACHMENTS_BASE_DIR)
puts "", "importing user avatars"
start = Time.now
@ -237,7 +237,7 @@ class BulkImport::Vanilla < BulkImport::Base
next
end
if !File.exists?(photo_path)
if !File.exist?(photo_path)
puts "Path to avatar file not found! Skipping. #{photo_path}"
next
end
@ -265,7 +265,7 @@ class BulkImport::Vanilla < BulkImport::Base
end
def import_attachments
if ATTACHMENTS_BASE_DIR && File.exists?(ATTACHMENTS_BASE_DIR)
if ATTACHMENTS_BASE_DIR && File.exist?(ATTACHMENTS_BASE_DIR)
puts "", "importing attachments"
start = Time.now
@ -297,7 +297,7 @@ class BulkImport::Vanilla < BulkImport::Base
path.gsub!("s3://uploads/", "")
file_path = "#{ATTACHMENTS_BASE_DIR}/#{path}"
if File.exists?(file_path)
if File.exist?(file_path)
upload = create_upload(post.user.id, file_path, File.basename(file_path))
if upload && upload.errors.empty?
# upload.url
@ -318,7 +318,7 @@ class BulkImport::Vanilla < BulkImport::Base
file_path = "#{ATTACHMENTS_BASE_DIR}/#{attachment_id}"
if File.exists?(file_path)
if File.exist?(file_path)
upload = create_upload(post.user.id, file_path, File.basename(file_path))
if upload && upload.errors.empty?
upload.url
@ -348,13 +348,13 @@ class BulkImport::Vanilla < BulkImport::Base
base_guess = base_filename.dup
full_guess = File.join(path, base_guess) # often an exact match exists
return full_guess if File.exists?(full_guess)
return full_guess if File.exist?(full_guess)
# Otherwise, the file exists but with a prefix:
# The p prefix seems to be the full file, so try to find that one first.
['p', 't', 'n'].each do |prefix|
full_guess = File.join(path, "#{prefix}#{base_guess}")
return full_guess if File.exists?(full_guess)
return full_guess if File.exist?(full_guess)
end
# Didn't find it.

View File

@ -531,7 +531,7 @@ class BulkImport::VBulletin < BulkImport::Base
real_filename = db_filename
real_filename.prepend SecureRandom.hex if real_filename[0] == '.'
unless File.exists?(filename)
unless File.exist?(filename)
puts "Attachment file #{row.inspect} doesn't exist"
return nil
end
@ -601,7 +601,7 @@ class BulkImport::VBulletin < BulkImport::Base
end
def import_avatars
if AVATAR_DIR && File.exists?(AVATAR_DIR)
if AVATAR_DIR && File.exist?(AVATAR_DIR)
puts "", "importing user avatars"
RateLimiter.disable
@ -620,7 +620,7 @@ class BulkImport::VBulletin < BulkImport::Base
# raise "User not found for id #{user_id}" if user.blank?
photo_real_filename = File.join(AVATAR_DIR, item)
puts "#{photo_real_filename} not found" unless File.exists?(photo_real_filename)
puts "#{photo_real_filename} not found" unless File.exist?(photo_real_filename)
upload = create_upload(u.id, photo_real_filename, File.basename(photo_real_filename))
count += 1

View File

@ -616,7 +616,7 @@ class BulkImport::VBulletin5 < BulkImport::Base
real_filename = db_filename
real_filename.prepend SecureRandom.hex if real_filename[0] == '.'
unless File.exists?(filename)
unless File.exist?(filename)
filename = check_database_for_attachment(row) if filename.blank?
return nil if filename.nil?
end