A platform for community discussion. Free, open, simple.
DEV: Fix methods removed in Ruby 3.2 (#15459)
Peter Zhuc5fd8c42dbf8
diff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rbindex d65baac29cc..2d339e9f545 100644--- a/app/controllers/user_avatars_controller.rb+++ b/app/controllers/user_avatars_controller.rb@@ -124,7 +124,7 @@ class UserAvatarsController < ApplicationControllerelsif upload && optimized = get_optimized_image(upload, size)if optimized.local?optimized_path = Discourse.store.path_for(optimized)- image = optimized_path if File.exists?(optimized_path)+ image = optimized_path if File.exist?(optimized_path)elsereturn proxy_avatar(Discourse.store.cdn_url(optimized.url), upload.created_at)enddiff --git a/app/jobs/regular/export_csv_file.rb b/app/jobs/regular/export_csv_file.rbindex 262e8719207..44305b44720 100644--- a/app/jobs/regular/export_csv_file.rb+++ b/app/jobs/regular/export_csv_file.rb@@ -56,7 +56,7 @@ module Jobsdirname = "#{UserExport.base_directory}/#{filename}"# ensure directory exists- FileUtils.mkdir_p(dirname) unless Dir.exists?(dirname)+ FileUtils.mkdir_p(dirname) unless Dir.exist?(dirname)# Generate a compressed CSV filebegindiff --git a/app/jobs/regular/export_user_archive.rb b/app/jobs/regular/export_user_archive.rbindex 4ff3f1fcb81..ba2442df774 100644--- a/app/jobs/regular/export_user_archive.rb+++ b/app/jobs/regular/export_user_archive.rb@@ -70,7 +70,7 @@ module Jobsdirname = "#{UserExport.base_directory}/#{filename}"# ensure directory exists- FileUtils.mkdir_p(dirname) unless Dir.exists?(dirname)+ FileUtils.mkdir_p(dirname) unless Dir.exist?(dirname)# Generate a compressed CSV filezip_filename = nildiff --git a/app/models/global_setting.rb b/app/models/global_setting.rbindex c83db37cfae..c39ceaefd92 100644--- a/app/models/global_setting.rb+++ b/app/models/global_setting.rb@@ -267,7 +267,7 @@ class GlobalSettingclass FileProvider < BaseProviderattr_reader :datadef self.from(file)- if File.exists?(file)+ if File.exist?(file)parse(file)endenddiff --git a/app/services/handle_chunk_upload.rb b/app/services/handle_chunk_upload.rbindex 2bd365b6432..d966f659aa1 100644--- a/app/services/handle_chunk_upload.rb+++ b/app/services/handle_chunk_upload.rb@@ -21,7 +21,7 @@ class HandleChunkUploaddef check_chunk# check whether the chunk has already been uploaded- has_chunk_been_uploaded = File.exists?(@chunk) && File.size(@chunk) == @params[:current_chunk_size]+ has_chunk_been_uploaded = File.exist?(@chunk) && File.size(@chunk) == @params[:current_chunk_size]# 200 = exists, 404 = not uploaded yetstatus = has_chunk_been_uploaded ? 200 : 404end@@ -30,7 +30,7 @@ class HandleChunkUpload# path to chunk filedir = File.dirname(@chunk)# ensure directory exists- FileUtils.mkdir_p(dir) unless Dir.exists?(dir)+ FileUtils.mkdir_p(dir) unless Dir.exist?(dir)# save chunk to the directoryFile.open(@chunk, "wb") { |f| f.write(@params[:file].tempfile.read) }enddiff --git a/bin/unicorn b/bin/unicornindex c52d2f8394d..9735e3eec0b 100755--- a/bin/unicorn+++ b/bin/unicorn@@ -26,7 +26,7 @@ def ensure_cache_clean!super_sha = Digest::SHA1.hexdigest(core_git_sha + plugins_combined_git_sha)hash_file = "#{RAILS_ROOT}/tmp/plugin-hash"- old_hash = File.exists?(hash_file) ? File.read(hash_file) : nil+ old_hash = File.exist?(hash_file) ? File.read(hash_file) : nilif old_hash && old_hash != super_shaputs "WARNING: It looks like your discourse plugins or core version have recently changed."diff --git a/config/boot.rb b/config/boot.rbindex f3b61fd24cc..6866506f24b 100644--- a/config/boot.rb+++ b/config/boot.rb@@ -10,7 +10,7 @@ require 'rubygems'# Set up gems listed in the Gemfile.ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)-require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])+require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])if (ENV['DISABLE_BOOTSNAP'] != '1')begindiff --git a/config/initializers/100-watch_for_restart.rb b/config/initializers/100-watch_for_restart.rbindex 922380cf675..0998cf01b19 100644--- a/config/initializers/100-watch_for_restart.rb+++ b/config/initializers/100-watch_for_restart.rb@@ -14,7 +14,7 @@Thread.new dofile = "#{Rails.root}/tmp/restart"- old_time = File.ctime(file).to_i if File.exists? file+ old_time = File.ctime(file).to_i if File.exist? filewait_seconds = 4if Rails.env.development? && $PROGRAM_NAME =~ /puma/@@ -25,7 +25,7 @@ Thread.new dobeginlistener = Listen.to("#{Rails.root}/tmp", only: /restart/) do- time = File.ctime(file).to_i if File.exists? file+ time = File.ctime(file).to_i if File.exist? fileif old_time != timeRails.logger.info "attempting to reload #{$$} #{$PROGRAM_NAME} in #{wait_seconds} seconds"diff --git a/config/unicorn.conf.rb b/config/unicorn.conf.rbindex b00fca1883f..50b0a622974 100644--- a/config/unicorn.conf.rb+++ b/config/unicorn.conf.rb@@ -71,7 +71,7 @@ before_fork do |server, worker|if supervisor > 0Thread.new dowhile true- unless File.exists?("/proc/#{supervisor}")+ unless File.exist?("/proc/#{supervisor}")puts "Kill self supervisor is gone"Process.kill "TERM", Process.pidenddiff --git a/lib/autospec/formatter.rb b/lib/autospec/formatter.rbindex 8b5b3ac4162..a6b26aff7ff 100644--- a/lib/autospec/formatter.rb+++ b/lib/autospec/formatter.rb@@ -13,8 +13,8 @@ class Autospec::Formatter < RSpec::Core::Formatters::BaseTextFormatterdef initialize(output)super- FileUtils.mkdir_p("tmp") unless Dir.exists?("tmp")- File.delete(RSPEC_RESULT) if File.exists?(RSPEC_RESULT)+ FileUtils.mkdir_p("tmp") unless Dir.exist?("tmp")+ File.delete(RSPEC_RESULT) if File.exist?(RSPEC_RESULT)@fail_file = File.open(RSPEC_RESULT, "w")enddiff --git a/lib/autospec/manager.rb b/lib/autospec/manager.rbindex bd8e49803b3..175f743aa90 100644--- a/lib/autospec/manager.rb+++ b/lib/autospec/manager.rb@@ -295,7 +295,7 @@ class Autospec::Managerif spec == file && linewith_line = spec + ":" << line.to_send- if File.exists?(spec) || Dir.exists?(spec)+ if File.exist?(spec) || Dir.exist?(spec)if with_line != specspecs << [file, spec, runner]enddiff --git a/lib/autospec/qunit_runner.rb b/lib/autospec/qunit_runner.rbindex ec76a240cd7..a50ed7593a3 100644--- a/lib/autospec/qunit_runner.rb+++ b/lib/autospec/qunit_runner.rb@@ -152,7 +152,7 @@ module Autospecdef try_to_find_module_name(file)file, _ = file.split(/:\d+$/)- return unless File.exists?(file)+ return unless File.exist?(file)File.open(file, "r").each_line do |line|if m = /module\(['"]([^'"]+)/i.match(line)return m[1]diff --git a/lib/autospec/reload_css.rb b/lib/autospec/reload_css.rbindex 54753e22ff5..8f24cdec984 100644--- a/lib/autospec/reload_css.rb+++ b/lib/autospec/reload_css.rb@@ -40,7 +40,7 @@ class Autospec::ReloadCsspaths.map! do |p|hash = nilfullpath = "#{Rails.root}/#{p}"- hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exists?(fullpath)+ hash = Digest::MD5.hexdigest(File.read(fullpath)) if File.exist?(fullpath)p = p.sub(/\.sass\.erb/, "")p = p.sub(/\.sass/, "")p = p.sub(/\.scss/, "")diff --git a/lib/backup_restore/backup_file_handler.rb b/lib/backup_restore/backup_file_handler.rbindex d9369789fb8..483d6f6473a 100644--- a/lib/backup_restore/backup_file_handler.rb+++ b/lib/backup_restore/backup_file_handler.rb@@ -86,7 +86,7 @@ module BackupRestoreif @is_archive# for compatibility with backups from Discourse v1.5 and belowold_dump_path = File.join(@tmp_directory, OLD_DUMP_FILENAME)- File.exists?(old_dump_path) ? old_dump_path : File.join(@tmp_directory, BackupRestore::DUMP_FILE)+ File.exist?(old_dump_path) ? old_dump_path : File.join(@tmp_directory, BackupRestore::DUMP_FILE)elseFile.join(@tmp_directory, @filename)enddiff --git a/lib/backup_restore/local_backup_store.rb b/lib/backup_restore/local_backup_store.rbindex 1b1cb977f5c..fd7f16b9f63 100644--- a/lib/backup_restore/local_backup_store.rb+++ b/lib/backup_restore/local_backup_store.rb@@ -7,7 +7,7 @@ module BackupRestoreroot_directory ||= File.join(Rails.root, "public", "backups")base_directory = File.join(root_directory, current_db)- FileUtils.mkdir_p(base_directory) unless Dir.exists?(base_directory)+ FileUtils.mkdir_p(base_directory) unless Dir.exist?(base_directory)base_directoryend@@ -25,13 +25,13 @@ module BackupRestoredef file(filename, include_download_source: false)path = path_from_filename(filename)- create_file_from_path(path, include_download_source) if File.exists?(path)+ create_file_from_path(path, include_download_source) if File.exist?(path)enddef delete_file(filename)path = path_from_filename(filename)- if File.exists?(path)+ if File.exist?(path)File.delete(path)reset_cacheenddiff --git a/lib/backup_restore/meta_data_handler.rb b/lib/backup_restore/meta_data_handler.rbindex 002bbd0d285..02bc0e98bf0 100644--- a/lib/backup_restore/meta_data_handler.rb+++ b/lib/backup_restore/meta_data_handler.rb@@ -42,7 +42,7 @@ module BackupRestoredef extract_metadatametadata_path = File.join(@tmp_directory, METADATA_FILE) if @tmp_directory.present?- if metadata_path.present? && File.exists?(metadata_path)+ if metadata_path.present? && File.exist?(metadata_path)metadata = load_metadata_file(metadata_path)elsif @filename =~ /-#{BackupRestore::VERSION_PREFIX}(\d{14})/metadata = { version: Regexp.last_match[1].to_i }diff --git a/lib/demon/base.rb b/lib/demon/base.rbindex 2d6d46e2955..397fb5d0b08 100644--- a/lib/demon/base.rb+++ b/lib/demon/base.rb@@ -151,7 +151,7 @@ class Demon::Baseenddef already_running?- if File.exists? pid_file+ if File.exist? pid_filepid = File.read(pid_file).to_iif Demon::Base.alive?(pid)return piddiff --git a/lib/discourse_dev/config.rb b/lib/discourse_dev/config.rbindex 4a2142b43c6..eb4a1d160bd 100644--- a/lib/discourse_dev/config.rb+++ b/lib/discourse_dev/config.rb@@ -12,7 +12,7 @@ module DiscourseDev@file_path = File.join(Rails.root, "config", "dev.yml")default_config = YAML.load_file(default_file_path)- if File.exists?(file_path)+ if File.exist?(file_path)user_config = YAML.load_file(file_path)elseputs "I did no detect a custom `config/dev.yml` file, creating one for you where you can amend defaults."diff --git a/lib/faker/discourse_markdown.rb b/lib/faker/discourse_markdown.rbindex b858e996c61..8f5266a1914 100644--- a/lib/faker/discourse_markdown.rb+++ b/lib/faker/discourse_markdown.rb@@ -72,7 +72,7 @@ module Fakerdef load_image(image)cache_path = ::File.join(image_cache_dir, image[:filename])- if !::File.exists?(cache_path)+ if !::File.exist?(cache_path)FileUtils.mkdir_p(image_cache_dir)temp_file = ::FileHelper.download(image[:url],diff --git a/lib/file_store/base_store.rb b/lib/file_store/base_store.rbindex 5d21449bcdb..eec747ba080 100644--- a/lib/file_store/base_store.rb+++ b/lib/file_store/base_store.rb@@ -173,7 +173,7 @@ module FileStoredef get_from_cache(filename)path = get_cache_path_for(filename)- File.open(path) if File.exists?(path)+ File.open(path) if File.exist?(path)enddef cache_file(file, filename)diff --git a/lib/file_store/local_store.rb b/lib/file_store/local_store.rbindex e71e3a6ba76..9e704efee98 100644--- a/lib/file_store/local_store.rb+++ b/lib/file_store/local_store.rb@@ -14,11 +14,11 @@ module FileStoredef 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 FileStoreenddef 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 FileStoredef 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 moveFile.open(path, "wb") { |f| f.write(file.read) }diff --git a/lib/i18n/locale_file_checker.rb b/lib/i18n/locale_file_checker.rbindex 757e9b969a2..4d0088ab8c6 100644--- a/lib/i18n/locale_file_checker.rb+++ b/lib/i18n/locale_file_checker.rb@@ -49,7 +49,7 @@ class LocaleFileCheckerdef reference_file(path)path = path.gsub(/\.\w{2,}\.yml$/, ".#{REFERENCE_LOCALE}.yml")- path if File.exists?(path)+ path if File.exist?(path)enddef traverse_hash(hash, parent_keys, &block)diff --git a/lib/letter_avatar.rb b/lib/letter_avatar.rbindex cdd054626a2..1a8524f338a 100644--- a/lib/letter_avatar.rb+++ b/lib/letter_avatar.rb@@ -42,10 +42,10 @@ class LetterAvatarsize = FULLSIZE if size > FULLSIZEfilename = cached_path(identity, size)- return filename if cache && File.exists?(filename)+ return filename if cache && File.exist?(filename)fullsize = fullsize_path(identity)- generate_fullsize(identity) if !cache || !File.exists?(fullsize)+ generate_fullsize(identity) if !cache || !File.exist?(fullsize)# Optimizing here is dubious, it can save up to 2x for large images (eg 359px)# BUT... we are talking 2400 bytes down to 1200 bytes, both fit in one packetdiff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rbindex 1e9526aceda..50f4ae04e10 100644--- a/lib/plugin/instance.rb+++ b/lib/plugin/instance.rb@@ -424,7 +424,7 @@ class Plugin::Instanceenddef delete_extra_automatic_assets(good_paths)- return unless Dir.exists? auto_generated_path+ return unless Dir.exist? auto_generated_pathfilenames = good_paths.map { |f| File.basename(f) }# nuke old files@@ -701,7 +701,7 @@ class Plugin::Instanceendpublic_data = File.dirname(path) + "/public"- if Dir.exists?(public_data)+ if Dir.exist?(public_data)target = Rails.root.to_s + "/public/plugins/"Discourse::Utils.execute_command('mkdir', '-p', target)@@ -839,7 +839,7 @@ class Plugin::Instanceenddef js_asset_exists?- File.exists?(js_file_path)+ File.exist?(js_file_path)end# Receives an array with two elements:@@ -1085,7 +1085,7 @@ class Plugin::Instanceenddef write_asset(path, contents)- unless File.exists?(path)+ unless File.exist?(path)ensure_directory(path)File.open(path, "w") { |f| f.write(contents) }enddiff --git a/lib/plugin_gem.rb b/lib/plugin_gem.rbindex 855d1aca2c1..c870680dbd7 100644--- a/lib/plugin_gem.rb+++ b/lib/plugin_gem.rb@@ -12,14 +12,14 @@ module PluginGemspec_file += "-#{opts[:platform]}" if opts[:platform]spec_file += ".gemspec"- unless File.exists? spec_file+ unless File.exist? spec_filecommand = "gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"command += " --source #{opts[:source]}" if opts[:source]puts commandputs `#{command}`end- if File.exists? spec_file+ if File.exist? spec_fileGem.path << gems_pathGem::Specification.load(spec_file).activatediff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rbindex 80239130c3b..c62ee62c81b 100644--- a/lib/s3_inventory.rb+++ b/lib/s3_inventory.rb@@ -140,7 +140,7 @@ class S3Inventoryenddef download_inventory_file_to_tmp_directory(file)- return if File.exists?(file[:filename])+ return if File.exist?(file[:filename])log "Downloading inventory file '#{file[:key]}' to tmp directory..."failure_message = "Failed to inventory file '#{file[:key]}' to tmp directory."@@ -219,8 +219,8 @@ class S3Inventorydef cleanup!return if @preloaded_inventory_filefiles.each do |file|- File.delete(file[:filename]) if File.exists?(file[:filename])- File.delete(file[:filename][0...-3]) if File.exists?(file[:filename][0...-3])+ File.delete(file[:filename]) if File.exist?(file[:filename])+ File.delete(file[:filename][0...-3]) if File.exist?(file[:filename][0...-3])endend@@ -253,7 +253,7 @@ class S3Inventorydef download_and_decompress_filesfiles.each do |file|- next if File.exists?(file[:filename][0...-3])+ next if File.exist?(file[:filename][0...-3])download_inventory_file_to_tmp_directory(file)decompress_inventory_file(file)diff --git a/lib/stylesheet/manager.rb b/lib/stylesheet/manager.rbindex a9b9c631b1f..43b5bdf1ed2 100644--- a/lib/stylesheet/manager.rb+++ b/lib/stylesheet/manager.rb@@ -107,7 +107,7 @@ class Stylesheet::Managerdef self.last_file_updatedif Rails.env.production?- @last_file_updated ||= if File.exists?(MANIFEST_FULL_PATH)+ @last_file_updated ||= if File.exist?(MANIFEST_FULL_PATH)File.readlines(MANIFEST_FULL_PATH, 'r')[0]elsemtime = max_file_mtime@@ -224,7 +224,7 @@ class Stylesheet::Managerbuilder = Builder.new(target: target, theme: theme, manager: self)next if builder.theme&.component && !scss_checker.has_scss(theme_id)- builder.compile unless File.exists?(builder.stylesheet_fullpath)+ builder.compile unless File.exist?(builder.stylesheet_fullpath)href = builder.stylesheet_path(current_hostname)data[:new_href] = href@@ -242,7 +242,7 @@ class Stylesheet::Managerendelsebuilder = Builder.new(target: target, manager: self)- builder.compile unless File.exists?(builder.stylesheet_fullpath)+ builder.compile unless File.exist?(builder.stylesheet_fullpath)href = builder.stylesheet_path(current_hostname)data = { target: target, new_href: href }@@ -285,7 +285,7 @@ class Stylesheet::Managermanager: self)- builder.compile unless File.exists?(builder.stylesheet_fullpath)+ builder.compile unless File.exist?(builder.stylesheet_fullpath)href = builder.stylesheet_path(current_hostname)stylesheet[:new_href] = hrefdiff --git a/lib/stylesheet/manager/builder.rb b/lib/stylesheet/manager/builder.rbindex 0b89cd8dc6c..b88730f1653 100644--- a/lib/stylesheet/manager/builder.rb+++ b/lib/stylesheet/manager/builder.rb@@ -12,7 +12,7 @@ class Stylesheet::Manager::Builderdef compile(opts = {})if !opts[:force]- if File.exists?(stylesheet_fullpath)+ if File.exist?(stylesheet_fullpath)unless StylesheetCache.where(target: qualified_target, digest: digest).exists?beginsource_map = begindiff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rakeindex 39bf7a3bf71..c8025a92cea 100644--- a/lib/tasks/assets.rake+++ b/lib/tasks/assets.rake@@ -260,7 +260,7 @@ def copy_ember_cli_assetsdest_sub = "#{dest}/#{Regexp.last_match[1]}"end- FileUtils.mkdir_p(dest_sub) unless Dir.exists?(dest_sub)+ FileUtils.mkdir_p(dest_sub) unless Dir.exist?(dest_sub)log_file = File.basename(rel_file).sub("-#{digest}", "")# It's simpler to serve the file as `application.js`@@ -362,7 +362,7 @@ task 'assets:precompile' => 'assets:precompile:before' do_file = (d = File.dirname(file)) == "." ? "_#{file}" : "#{d}/_#{File.basename(file)}"_path = "#{assets_path}/#{_file}"max_compress = max_compress?(info["logical_path"], locales)- if File.exists?(_path)+ if File.exist?(_path)STDERR.puts "Skipping: #{file} already compressed"elsif file.include? "discourse/tests"STDERR.puts "Skipping: #{file}"diff --git a/lib/tasks/emoji.rake b/lib/tasks/emoji.rakeindex 07b0046aa39..dc92250cdd5 100644--- a/lib/tasks/emoji.rake+++ b/lib/tasks/emoji.rake@@ -511,12 +511,12 @@ class TestEmojiUpdate < MiniTest::Testenddef test_groups_js_es6_creation- assert File.exists?(EMOJI_GROUPS_PATH)+ assert File.exist?(EMOJI_GROUPS_PATH)assert File.size?(EMOJI_GROUPS_PATH)enddef test_db_json_creation- assert File.exists?(EMOJI_DB_PATH)+ assert File.exist?(EMOJI_DB_PATH)assert File.size?(EMOJI_DB_PATH)end@@ -536,12 +536,12 @@ class TestEmojiUpdate < MiniTest::Testdef test_scalesoriginal_image = image_path("apple", "blonde_woman")- assert File.exists?(original_image)+ assert File.exist?(original_image)assert File.size?(original_image)(2..6).each do |scale|image = image_path("apple", "blonde_woman/#{scale}")- assert File.exists?(image)+ assert File.exist?(image)assert File.size?(image)endenddiff --git a/lib/tasks/javascript.rake b/lib/tasks/javascript.rakeindex 2c09ce9dd04..70570efe0bd 100644--- a/lib/tasks/javascript.rake+++ b/lib/tasks/javascript.rake@@ -307,7 +307,7 @@ task 'javascript:update' => 'clean_up' dopath = "#{public_js}/#{package_dir_name}/#{package_version}"dest = "#{path}/#{filename}"- FileUtils.mkdir_p(path) unless File.exists?(path)+ FileUtils.mkdir_p(path) unless File.exist?(path)endelsedest = "#{vendor_js}/#{filename}"@@ -336,7 +336,7 @@ task 'javascript:update' => 'clean_up' dosystem("yarn run browserify #{vendor_js}/custom-uppy.js -o node_modules/custom-uppy-build.js")end- unless File.exists?(dest)+ unless File.exist?(dest)STDERR.puts "New dependency added: #{dest}"enddiff --git a/lib/tasks/release_note.rake b/lib/tasks/release_note.rakeindex 0b75aae5224..eb3cf8f737a 100644--- a/lib/tasks/release_note.rake+++ b/lib/tasks/release_note.rake@@ -37,7 +37,7 @@ task "release_note:plugins:generate", :from, :to, :plugin_glob, :org do |t, argsplugin_glob = args[:plugin_glob] || "./plugins/*"git_org = args[:org]- all_repos = Dir.glob(plugin_glob).filter { |f| File.directory?(f) && File.exists?("#{f}/.git") }+ all_repos = Dir.glob(plugin_glob).filter { |f| File.directory?(f) && File.exist?("#{f}/.git") }if git_orgall_repos = all_repos.filter { |dir| `git -C #{dir} remote get-url origin`.match?(/github.com[\/:]#{git_org}\//) }diff --git a/lib/tasks/s3.rake b/lib/tasks/s3.rakeindex 7b7258d6d47..2c54f9f6a49 100644--- a/lib/tasks/s3.rake+++ b/lib/tasks/s3.rake@@ -38,7 +38,7 @@ def upload(path, remote_path, content_type, content_encoding = nil)endend- File.delete(path) if (File.exists?(path) && ENV["DELETE_ASSETS_AFTER_S3_UPLOAD"])+ File.delete(path) if (File.exist?(path) && ENV["DELETE_ASSETS_AFTER_S3_UPLOAD"])enddef use_db_s3_configdiff --git a/lib/tasks/site.rake b/lib/tasks/site.rakeindex ba984bd4037..9a05d5fd96c 100644--- a/lib/tasks/site.rake+++ b/lib/tasks/site.rake@@ -97,7 +97,7 @@ task 'site:export_structure', [:zip_path] => :environment do |task, args|if args[:zip_path].blank?STDERR.puts "ERROR: rake site:export_structure[<path to ZIP file>]"exit 1- elsif File.exists?(args[:zip_path])+ elsif File.exist?(args[:zip_path])STDERR.puts "ERROR: File '#{args[:zip_path]}' already exists"exit 2end@@ -328,7 +328,7 @@ task 'site:import_structure', [:zip_path] => :environment do |task, args|if args[:zip_path].blank?STDERR.puts "ERROR: rake site:import_structure[<path to ZIP file>]"exit 1- elsif !File.exists?(args[:zip_path])+ elsif !File.exist?(args[:zip_path])STDERR.puts "ERROR: File '#{args[:zip_path]}' does not exist"exit 2enddiff --git a/lib/tasks/smoke_test.rake b/lib/tasks/smoke_test.rakeindex 4f48dff0c0a..cc686ddf223 100644--- a/lib/tasks/smoke_test.rake+++ b/lib/tasks/smoke_test.rake@@ -31,7 +31,7 @@ task "smoke:test" doenddir = ENV["SMOKE_TEST_SCREENSHOT_PATH"] || 'tmp/smoke-test-screenshots'- FileUtils.mkdir_p(dir) unless Dir.exists?(dir)+ FileUtils.mkdir_p(dir) unless Dir.exist?(dir)wait = ENV["WAIT_FOR_URL"].to_idiff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rakeindex 924ee605030..4a043ca1517 100644--- a/lib/tasks/uploads.rake+++ b/lib/tasks/uploads.rake@@ -19,7 +19,7 @@ def gather_uploads_for_all_sitesenddef file_exists?(path)- File.exists?(path) && File.size(path) > 0+ File.exist?(path) && File.size(path) > 0rescuefalseend@@ -188,7 +188,7 @@ def clean_up_uploadsUpload.find_each do |upload|path = File.join(public_directory, upload.url)- if !File.exists?(path)+ if !File.exist?(path)upload.destroy!putc "#"else@@ -200,7 +200,7 @@ def clean_up_uploadsOptimizedImage.find_each do |optimized_image|path = File.join(public_directory, optimized_image.url)- if !File.exists?(path)+ if !File.exist?(path)optimized_image.destroy!putc "#"else@@ -326,9 +326,9 @@ def regenerate_missing_optimizedthumbnail = "#{public_directory}#{optimized_image.url}"original = "#{public_directory}#{upload.url}"- if !File.exists?(thumbnail) || File.size(thumbnail) <= 0+ if !File.exist?(thumbnail) || File.size(thumbnail) <= 0# make sure the original image exists locally- if (!File.exists?(original) || File.size(original) <= 0) && upload.origin.present?+ if (!File.exist?(original) || File.size(original) <= 0) && upload.origin.present?# try to fix it by redownloading itbegindownloaded = FileHelper.download(@@ -346,7 +346,7 @@ def regenerate_missing_optimizedendend- if File.exists?(original) && File.size(original) > 0+ if File.exist?(original) && File.size(original) > 0FileUtils.mkdir_p(File.dirname(thumbnail))OptimizedImage.resize(original, thumbnail, optimized_image.width, optimized_image.height)putc "#"diff --git a/lib/temporary_db.rb b/lib/temporary_db.rbindex 3b7a42e9b5e..1bcffa570d8 100644--- a/lib/temporary_db.rb+++ b/lib/temporary_db.rb@@ -24,7 +24,7 @@ class TemporaryDbendif !@pg_bin_pathbin_path = "/Applications/Postgres.app/Contents/Versions/latest/bin"- if File.exists?("#{bin_path}/pg_ctl")+ if File.exist?("#{bin_path}/pg_ctl")@pg_bin_path = bin_pathendenddiff --git a/script/bench.rb b/script/bench.rbindex d1ab78d791a..86f6c6c73cf 100644--- a/script/bench.rb+++ b/script/bench.rb@@ -112,7 +112,7 @@ unless $? == 0abort "Apache Bench is not installed. Try: apt-get install apache2-utils or brew install ab"end-unless File.exists?("config/database.yml")+unless File.exist?("config/database.yml")puts "Copying database.yml.development.sample to database.yml"`cp config/database.yml.development-sample config/database.yml`enddiff --git a/script/bulk_import/discourse_merger.rb b/script/bulk_import/discourse_merger.rbindex da2a9c6a114..e1ab58c83c3 100644--- a/script/bulk_import/discourse_merger.rb+++ b/script/bulk_import/discourse_merger.rb@@ -359,7 +359,7 @@ class BulkImport::DiscourseMerger < BulkImport::Basenext 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)enddiff --git a/script/bulk_import/vanilla.rb b/script/bulk_import/vanilla.rbindex cb85b853f93..d01eed3af03 100644--- a/script/bulk_import/vanilla.rb+++ b/script/bulk_import/vanilla.rb@@ -203,7 +203,7 @@ class BulkImport::Vanilla < BulkImport::Baseenddef 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::Basenextend- if !File.exists?(photo_path)+ if !File.exist?(photo_path)puts "Path to avatar file not found! Skipping. #{photo_path}"nextend@@ -265,7 +265,7 @@ class BulkImport::Vanilla < BulkImport::Baseenddef 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::Basepath.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::Basefile_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::Basebase_guess = base_filename.dupfull_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.diff --git a/script/bulk_import/vbulletin.rb b/script/bulk_import/vbulletin.rbindex 8a57522002c..511d7a8cea2 100644--- a/script/bulk_import/vbulletin.rb+++ b/script/bulk_import/vbulletin.rb@@ -531,7 +531,7 @@ class BulkImport::VBulletin < BulkImport::Basereal_filename = db_filenamereal_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 nilend@@ -601,7 +601,7 @@ class BulkImport::VBulletin < BulkImport::Baseenddef 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 += 1diff --git a/script/bulk_import/vbulletin5.rb b/script/bulk_import/vbulletin5.rbindex 507eb3d5d2c..9be967c25c4 100644--- a/script/bulk_import/vbulletin5.rb+++ b/script/bulk_import/vbulletin5.rb@@ -616,7 +616,7 @@ class BulkImport::VBulletin5 < BulkImport::Basereal_filename = db_filenamereal_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?enddiff --git a/script/import_scripts/answerhub.rb b/script/import_scripts/answerhub.rbindex 035d625c293..f2e05811bac 100644--- a/script/import_scripts/answerhub.rb+++ b/script/import_scripts/answerhub.rb@@ -367,7 +367,7 @@ class ImportScripts::AnswerHub < ImportScripts::Baseif userfilename = "avatar-#{user_id}.png"path = File.join(AVATAR_DIR, filename)- next if !File.exists?(path)+ next if !File.exist?(path)# Scrape Avatars - Avatars are saved in the db, but it might be easier to just scrape themif SCRAPE_AVATARS == 1@@ -403,7 +403,7 @@ class ImportScripts::AnswerHub < ImportScripts::Basefilepath = File.basename(image).split('"')[0]filepath = File.join(ATTACHMENT_DIR, filepath)- if File.exists?(filepath)+ if File.exist?(filepath)filename = File.basename(filepath)upload = create_upload(user_id, filepath, filename)image_html = html_for_upload(upload, filename)@@ -421,7 +421,7 @@ class ImportScripts::AnswerHub < ImportScripts::Basefilepath = File.basename(file).split('"')[0]filepath = File.join(ATTACHMENT_DIR, filepath)- if File.exists?(filepath)+ if File.exist?(filepath)filename = File.basename(filepath)upload = create_upload(user_id, filepath, filename)file_html = html_for_upload(upload, filename)diff --git a/script/import_scripts/base/generic_database.rb b/script/import_scripts/base/generic_database.rbindex 2b10e0c25ad..28bfd8ee3bf 100644--- a/script/import_scripts/base/generic_database.rb+++ b/script/import_scripts/base/generic_database.rb@@ -6,7 +6,7 @@ module ImportScriptsclass GenericDatabasedef initialize(directory, batch_size:, recreate: false, numeric_keys: false)filename = "#{directory}/index.db"- File.delete(filename) if recreate && File.exists?(filename)+ File.delete(filename) if recreate && File.exist?(filename)@db = SQLite3::Database.new(filename, results_as_hash: true)@batch_size = batch_sizediff --git a/script/import_scripts/bbpress.rb b/script/import_scripts/bbpress.rbindex 1db8c2c0d8c..2cd0698d123 100644--- a/script/import_scripts/bbpress.rb+++ b/script/import_scripts/bbpress.rb@@ -316,7 +316,7 @@ class ImportScripts::Bbpress < ImportScripts::Baseattachments.each do |a|print_status(count += 1, total_attachments, get_start_time("attachments_from_postmeta"))path = File.join(BB_PRESS_ATTACHMENTS_DIR, a["meta_value"])- if File.exists?(path)+ if File.exist?(path)if post = Post.find_by(id: post_id_from_imported_post_id(a["post_id"]))filename = File.basename(a["meta_value"])upload = create_upload(post.user.id, path, filename)diff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rbindex edced0e7ab3..1b3cb5b8cbc 100644--- a/script/import_scripts/discuz_x.rb+++ b/script/import_scripts/discuz_x.rb@@ -927,7 +927,7 @@ class ImportScripts::DiscuzX < ImportScripts::Baseendfilename = File.join(DISCUZX_BASE_DIR, ATTACHMENT_DIR, row['attachment_path'])- unless File.exists?(filename)+ unless File.exist?(filename)puts "Attachment file doesn't exist: #{filename}"return nilenddiff --git a/script/import_scripts/drupal.rb b/script/import_scripts/drupal.rbindex a10615fe320..23348c055bf 100644--- a/script/import_scripts/drupal.rb+++ b/script/import_scripts/drupal.rb@@ -428,7 +428,7 @@ class ImportScripts::Drupal < ImportScripts::Basereal_filename = CGI.unescapeHTML(uri)file = File.join(ATTACHMENT_DIR, real_filename)- unless File.exists?(file)+ unless File.exist?(file)puts "Attachment file #{attachment['filename']} doesn't exist"tmpfile = "attachments_failed.txt"diff --git a/script/import_scripts/drupal_json.rb b/script/import_scripts/drupal_json.rbindex 3b72e7d61ad..d69f21e01bd 100644--- a/script/import_scripts/drupal_json.rb+++ b/script/import_scripts/drupal_json.rb@@ -23,7 +23,7 @@ class ImportScripts::DrupalJson < ImportScripts::Basedef load_json(arg)filename = File.join(JSON_FILES_DIR, arg)- raise RuntimeError.new("File #{filename} not found!") if !File.exists?(filename)+ raise RuntimeError.new("File #{filename} not found!") if !File.exist?(filename)JSON.parse(File.read(filename)).reverseenddiff --git a/script/import_scripts/friendsmegplus.rb b/script/import_scripts/friendsmegplus.rbindex ee22dd9cbca..d66eed12cc1 100644--- a/script/import_scripts/friendsmegplus.rb+++ b/script/import_scripts/friendsmegplus.rb@@ -178,7 +178,7 @@ class ImportScripts::FMGP < ImportScripts::Baseenddef load_fmgp_json(filename)- raise RuntimeError.new("File #{filename} not found") if !File.exists?(filename)+ raise RuntimeError.new("File #{filename} not found") if !File.exist?(filename)JSON.parse(File.read(filename))enddiff --git a/script/import_scripts/getsatisfaction.rb b/script/import_scripts/getsatisfaction.rbindex 495cc50c0ed..50f8613e683 100644--- a/script/import_scripts/getsatisfaction.rb+++ b/script/import_scripts/getsatisfaction.rb@@ -69,7 +69,7 @@ class ImportScripts::GetSatisfaction < ImportScripts::Basedef csv_filename(table_name, use_fixed: true)if use_fixedfilename = File.join(@path, "#{table_name}_fixed.csv")- return filename if File.exists?(filename)+ return filename if File.exist?(filename)endFile.join(@path, "#{table_name}.csv")diff --git a/script/import_scripts/google_groups.rb b/script/import_scripts/google_groups.rbindex 359114e6627..ab7bb303895 100755--- a/script/import_scripts/google_groups.rb+++ b/script/import_scripts/google_groups.rb@@ -223,7 +223,7 @@ def crawlstart_time = Time.nowstatus_filename = File.join(@path, "status.yml")- if File.exists?(status_filename)+ if File.exist?(status_filename)yaml = YAML.load_file(status_filename)@finished = yaml[:finished]@scraped_topic_urls = yaml[:urls]diff --git a/script/import_scripts/higher_logic.rb b/script/import_scripts/higher_logic.rbindex 1f5b1d9599e..fe6e19641dd 100644--- a/script/import_scripts/higher_logic.rb+++ b/script/import_scripts/higher_logic.rb@@ -195,7 +195,7 @@ class ImportScripts::HigherLogic < ImportScripts::Baseoriginal_filename = "#{a['VersionName']}.#{a['FileExtension']}"path = File.join(ATTACHMENT_DIR, original_filename)- if File.exists?(path)+ if File.exist?(path)if post = Post.find(post_id_from_imported_post_id(a['MessageKey']))filename = File.basename(original_filename)upload = create_upload(post.user.id, path, filename)diff --git a/script/import_scripts/ipboard.rb b/script/import_scripts/ipboard.rbindex b849f75a47c..3f418ab5380 100644--- a/script/import_scripts/ipboard.rb+++ b/script/import_scripts/ipboard.rb@@ -213,7 +213,7 @@ EOMpost_create_action: proc do |newuser|if user['avatar_url'] && user['avatar_url'].length > 0photo_path = AVATARS_DIR + user['avatar_url']- if File.exists?(photo_path)+ if File.exist?(photo_path)beginupload = create_upload(newuser.id, photo_path, File.basename(photo_path))if upload && upload.persisted?diff --git a/script/import_scripts/ipboard3.rb b/script/import_scripts/ipboard3.rbindex 4e7638633df..2ea180c901b 100644--- a/script/import_scripts/ipboard3.rb+++ b/script/import_scripts/ipboard3.rb@@ -87,7 +87,7 @@ class ImportScripts::IPBoard3 < ImportScripts::Basenew_user.update(suspended_at: DateTime.now, suspended_till: 100.years.from_now)elsif u["pp_main_photo"].present?path = File.join(UPLOADS_DIR, u["pp_main_photo"])- if File.exists?(path)+ if File.exist?(path)beginupload = create_upload(new_user.id, path, File.basename(path))if upload.persisted?@@ -390,7 +390,7 @@ class ImportScripts::IPBoard3 < ImportScripts::Basemarkdown.gsub!(/\[attachment=(\d+):.+\]/) doif a = mysql_query("SELECT attach_file, attach_location FROM attachments WHERE attach_id = #{$1}").firstpath = File.join(UPLOADS_DIR, a["attach_location"])- if File.exists?(path)+ if File.exist?(path)beginupload = create_upload(user_id, path, a["attach_file"])return html_for_upload(upload, a["attach_file"]) if upload.persisted?diff --git a/script/import_scripts/lithium.rb b/script/import_scripts/lithium.rbindex 161618a7c16..1d258e7cac0 100644--- a/script/import_scripts/lithium.rb+++ b/script/import_scripts/lithium.rb@@ -842,7 +842,7 @@ SQLfilename = attachment_id.to_s.rjust(4, "0")filename = File.join(ATTACHMENT_DIR, "000#{filename[0]}/#{filename}.dat")- unless File.exists?(filename)+ unless File.exist?(filename)puts "Attachment file doesn't exist: #{filename}"return nilend@@ -953,9 +953,9 @@ SQL# check to see if we have itif File.exist?(png)image = png- elsif File.exists?(jpg)+ elsif File.exist?(jpg)image = jpg- elsif File.exists?(gif)+ elsif File.exist?(gif)image = gifenddiff --git a/script/import_scripts/mbox.rb b/script/import_scripts/mbox.rbindex cee093033fc..d712a5055d2 100644--- a/script/import_scripts/mbox.rb+++ b/script/import_scripts/mbox.rb@@ -1,6 +1,6 @@# frozen_string_literal: true-if ARGV.length != 1 || !File.exists?(ARGV[0])+if ARGV.length != 1 || !File.exist?(ARGV[0])STDERR.puts '', 'Usage of mbox importer:', 'bundle exec ruby mbox.rb <path/to/settings.yml>'STDERR.puts '', "Use the settings file from #{File.expand_path('mbox/settings.yml', File.dirname(__FILE__))} as an example."exit 1diff --git a/script/import_scripts/modx.rb b/script/import_scripts/modx.rbindex 0cb4f6d8c46..d2031bd3364 100644--- a/script/import_scripts/modx.rb+++ b/script/import_scripts/modx.rb@@ -261,7 +261,7 @@ FROM #{TABLE_PREFIX}discuss_usersendfilename = File.join(ATTACHMENT_DIR, row['user_id'].to_s.split('').join('/'), "#{row['file_id']}.attach")- unless File.exists?(filename)+ unless File.exist?(filename)puts "Attachment file doesn't exist: #{filename}"returnenddiff --git a/script/import_scripts/ning.rb b/script/import_scripts/ning.rbindex 712f07b8617..30612ec9691 100644--- a/script/import_scripts/ning.rb+++ b/script/import_scripts/ning.rb@@ -55,7 +55,7 @@ class ImportScripts::Ning < ImportScripts::Basedef load_ning_json(arg)filename = File.join(JSON_FILES_DIR, arg)- raise RuntimeError.new("File #{filename} not found!") if !File.exists?(filename)+ raise RuntimeError.new("File #{filename} not found!") if !File.exist?(filename)JSON.parse(repair_json(File.read(filename))).reverseend@@ -112,7 +112,7 @@ class ImportScripts::Ning < ImportScripts::Baseif u["profilePhoto"] && newuser.user_avatar.try(:custom_upload_id).nil?photo_path = file_full_path(u["profilePhoto"])- if File.exists?(photo_path)+ if File.exist?(photo_path)beginupload = create_upload(newuser.id, photo_path, File.basename(photo_path))if upload.persisted?@@ -315,7 +315,7 @@ class ImportScripts::Ning < ImportScripts::Basening_filename = matches[1]filename = File.join(JSON_FILES_DIR, ning_filename.split("?").first)- if !File.exists?(filename)+ if !File.exist?(filename)puts "Attachment file doesn't exist: #{filename}"next send@@ -339,7 +339,7 @@ class ImportScripts::Ning < ImportScripts::Basefile_names.each do |f|filename = File.join(JSON_FILES_DIR, f.split("?").first)- if !File.exists?(filename)+ if !File.exist?(filename)puts "Attachment file doesn't exist: #{filename}"nextend@@ -363,7 +363,7 @@ class ImportScripts::Ning < ImportScripts::Base# filename = File.join(JSON_FILES_DIR, file_name)filename = file_full_path(file_name)- if File.exists?(filename)+ if File.exist?(filename)upload = create_upload(@system_user.id, filename, File.basename(filename))if upload.nil? || !upload.valid?diff --git a/script/import_scripts/nodebb/nodebb.rb b/script/import_scripts/nodebb/nodebb.rbindex 5fed857301d..b29f5ee1c6c 100644--- a/script/import_scripts/nodebb/nodebb.rb+++ b/script/import_scripts/nodebb/nodebb.rb@@ -216,7 +216,7 @@ class ImportScripts::NodeBB < ImportScripts::Basefilepath = File.join(ATTACHMENT_DIR, picture)filename = File.basename(picture)- unless File.exists?(filepath)+ unless File.exist?(filepath)puts "Avatar file doesn't exist: #{filepath}"return nilend@@ -276,7 +276,7 @@ class ImportScripts::NodeBB < ImportScripts::Basefilepath = File.join(ATTACHMENT_DIR, picture)filename = File.basename(picture)- unless File.exists?(filepath)+ unless File.exist?(filepath)puts "Background file doesn't exist: #{filepath}"return nilend@@ -481,7 +481,7 @@ class ImportScripts::NodeBB < ImportScripts::Base# if file exists# upload attachment and return html for it- if File.exists?(filepath)+ if File.exist?(filepath)filename = File.basename(filepath)upload = create_upload(post.user_id, filepath, filename)diff --git a/script/import_scripts/phpbb3.rb b/script/import_scripts/phpbb3.rbindex 3808b511b17..4ee79d14ed0 100644--- a/script/import_scripts/phpbb3.rb+++ b/script/import_scripts/phpbb3.rb@@ -3,7 +3,7 @@# Importer for phpBB 3.0 and 3.1# Documentation: https://meta.discourse.org/t/importing-from-phpbb3/30810-if ARGV.length != 1 || !File.exists?(ARGV[0])+if ARGV.length != 1 || !File.exist?(ARGV[0])STDERR.puts '', 'Usage of phpBB3 importer:', 'bundle exec ruby phpbb3.rb <path/to/settings.yml>'STDERR.puts '', "Use the settings file from #{File.expand_path('phpbb3/settings.yml', File.dirname(__FILE__))} as an example."STDERR.puts '', 'Still having problems? Take a look at https://meta.discourse.org/t/importing-from-phpbb3/30810'diff --git a/script/import_scripts/smf1.rb b/script/import_scripts/smf1.rbindex 5f83eef6734..90ec314ea97 100644--- a/script/import_scripts/smf1.rb+++ b/script/import_scripts/smf1.rb@@ -411,7 +411,7 @@ class ImportScripts::Smf1 < ImportScripts::Basenext unless post = PostCustomField.joins(:post).find_by(name: "import_id", value: u["id_msg"].to_s)&.postpath = File.join(UPLOADS_DIR, "#{u["id_attach"]}_#{u["file_hash"]}")- next unless File.exists?(path) && File.size(path) > 0+ next unless File.exist?(path) && File.size(path) > 0if upload = create_upload(post.user_id, path, u["filename"])html = html_for_upload(upload, u["filename"])diff --git a/script/import_scripts/smf2.rb b/script/import_scripts/smf2.rbindex 9885f1edc32..a70faff4cb9 100644--- a/script/import_scripts/smf2.rb+++ b/script/import_scripts/smf2.rb@@ -303,7 +303,7 @@ class ImportScripts::Smf2 < ImportScripts::Base[ filename, "#{attachment_id}_#{file_hash}", legacy_name ].map { |name| File.join(options.smfroot, 'attachments', name) }- .detect { |file| File.exists?(file) }+ .detect { |file| File.exist?(file) }enddef decode_entities(*args)diff --git a/script/import_scripts/vanilla_mysql.rb b/script/import_scripts/vanilla_mysql.rbindex da20a58257d..d0a5e348934 100644--- a/script/import_scripts/vanilla_mysql.rb+++ b/script/import_scripts/vanilla_mysql.rb@@ -156,7 +156,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Baseenddef import_avatars- if ATTACHMENTS_BASE_DIR && File.exists?(ATTACHMENTS_BASE_DIR)+ if ATTACHMENTS_BASE_DIR && File.exist?(ATTACHMENTS_BASE_DIR)puts "", "importing user avatars"User.find_each do |u|@@ -183,7 +183,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Basenextend- if !File.exists?(photo_path)+ if !File.exist?(photo_path)puts "Path to avatar file not found! Skipping. #{photo_path}"nextend@@ -214,13 +214,13 @@ class ImportScripts::VanillaSQL < ImportScripts::Basebase_guess = base_filename.dupfull_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.@@ -554,7 +554,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Baseenddef 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@@ -586,7 +586,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Basepath.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@@ -607,7 +607,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Basefile_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.urldiff --git a/script/import_scripts/vbulletin.rb b/script/import_scripts/vbulletin.rbindex d998daa916d..9107823d3f0 100644--- a/script/import_scripts/vbulletin.rb+++ b/script/import_scripts/vbulletin.rb@@ -426,7 +426,7 @@ EOMreal_filename = row['filename']real_filename.prepend SecureRandom.hex if real_filename[0] == '.'- unless File.exists?(filename)+ unless File.exist?(filename)if row['dbsize'].to_i == 0puts "Attachment file #{row['filedataid']} doesn't exist"return nildiff --git a/script/import_scripts/vbulletin5.rb b/script/import_scripts/vbulletin5.rbindex bdf80dcd3b1..5e5696e4f0f 100644--- a/script/import_scripts/vbulletin5.rb+++ b/script/import_scripts/vbulletin5.rb@@ -138,7 +138,7 @@ class ImportScripts::VBulletin < ImportScripts::Baseupload = UploadCreator.new(file, picture["filename"]).create_for(imported_user.id)elsefilename = File.join(AVATAR_DIR, picture['filename'])- unless File.exists?(filename)+ unless File.exist?(filename)puts "Avatar file doesn't exist: #{filename}"return nilend@@ -366,7 +366,7 @@ class ImportScripts::VBulletin < ImportScripts::Basereal_filename = upload['filename']real_filename.prepend SecureRandom.hex if real_filename[0] == '.'- unless File.exists?(filename)+ unless File.exist?(filename)# attachments can be on filesystem or in database# try to retrieve from database if the file did not exist on filesystemif upload['dbsize'].to_i == 0diff --git a/spec/components/common_passwords/common_passwords_spec.rb b/spec/components/common_passwords/common_passwords_spec.rbindex deccf6a5d52..c68620d6e9e 100644--- a/spec/components/common_passwords/common_passwords_spec.rb+++ b/spec/components/common_passwords/common_passwords_spec.rb@@ -5,7 +5,7 @@ require "rails_helper"describe CommonPasswords doit "the passwords file should exist" do- expect(File.exists?(described_class::PASSWORD_FILE)).to eq(true)+ expect(File.exist?(described_class::PASSWORD_FILE)).to eq(true)enddescribe "#common_password?" dodiff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rbindex 8e68bf7ae84..40ce9e49b82 100644--- a/spec/components/oneboxer_spec.rb+++ b/spec/components/oneboxer_spec.rb@@ -5,7 +5,7 @@ require 'rails_helper'describe Oneboxer dodef response(file)file = File.join("spec", "fixtures", "onebox", "#{file}.response")- File.exists?(file) ? File.read(file) : ""+ File.exist?(file) ? File.read(file) : ""endit "returns blank string for an invalid onebox" dodiff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rbindex 506ac7e09ed..fd3c3864522 100644--- a/spec/components/plugin/instance_spec.rb+++ b/spec/components/plugin/instance_spec.rb@@ -230,11 +230,11 @@ describe Plugin::Instance do# calls ensure_assets! make sure they are thereexpect(plugin.assets.count).to eq(1)plugin.assets.each do |a, opts|- expect(File.exists?(a)).to eq(true)+ expect(File.exist?(a)).to eq(true)end# ensure it cleans up all crap in autogenerated directory- expect(File.exists?(junk_file)).to eq(false)+ expect(File.exist?(junk_file)).to eq(false)endit "registers auth providers correctly" dodiff --git a/spec/lib/backup_restore/local_backup_store_spec.rb b/spec/lib/backup_restore/local_backup_store_spec.rbindex 5247daf28bd..3cf1ea42518 100644--- a/spec/lib/backup_restore/local_backup_store_spec.rb+++ b/spec/lib/backup_restore/local_backup_store_spec.rb@@ -36,16 +36,16 @@ describe BackupRestore::LocalBackupStore doenddef remove_backups- @paths.each { |path| File.delete(path) if File.exists?(path) }+ @paths.each { |path| File.delete(path) if File.exist?(path) }@paths.clearenddef create_file(db_name:, filename:, last_modified:, size_in_bytes:)path = File.join(@root_directory, db_name)- Dir.mkdir(path) unless Dir.exists?(path)+ Dir.mkdir(path) unless Dir.exist?(path)path = File.join(path, filename)- return if File.exists?(path)+ return if File.exist?(path)@paths << pathFileUtils.touch(path)diff --git a/spec/lib/backup_restore/shared_examples_for_backup_store.rb b/spec/lib/backup_restore/shared_examples_for_backup_store.rbindex 726fd511411..21f0a515bae 100644--- a/spec/lib/backup_restore/shared_examples_for_backup_store.rb+++ b/spec/lib/backup_restore/shared_examples_for_backup_store.rb@@ -174,7 +174,7 @@ shared_examples "backup store" dodestination_path = File.join(path, File.basename(filename))store.download_file(filename, destination_path)- expect(File.exists?(destination_path)).to eq(true)+ expect(File.exist?(destination_path)).to eq(true)expect(File.size(destination_path)).to eq(backup1.size)endenddiff --git a/spec/lib/upload_recovery_spec.rb b/spec/lib/upload_recovery_spec.rbindex 4ab612b33f0..a0fc0ec4ba6 100644--- a/spec/lib/upload_recovery_spec.rb+++ b/spec/lib/upload_recovery_spec.rb@@ -41,7 +41,7 @@ RSpec.describe UploadRecovery do[public_path,public_path.sub("uploads", "uploads/tombstone")- ].each { |path| File.delete(path) if File.exists?(path) }+ ].each { |path| File.delete(path) if File.exist?(path) }endenddiff --git a/spec/models/optimized_image_spec.rb b/spec/models/optimized_image_spec.rbindex 4139e83b890..2fc1b0f6601 100644--- a/spec/models/optimized_image_spec.rb+++ b/spec/models/optimized_image_spec.rb@@ -28,7 +28,7 @@ describe OptimizedImage doexpect(cropped_size).to be > 50ensure- File.delete(tmp_path) if File.exists?(tmp_path)+ File.delete(tmp_path) if File.exist?(tmp_path)endend@@ -73,7 +73,7 @@ describe OptimizedImage doexpect(new_size).not_to eq(0)ensure- File.delete(original_path) if File.exists?(original_path)+ File.delete(original_path) if File.exist?(original_path)endend@@ -124,7 +124,7 @@ describe OptimizedImage do)end.to raise_error(RuntimeError, /improper image header/)ensure- File.delete(tmp_path) if File.exists?(tmp_path)+ File.delete(tmp_path) if File.exist?(tmp_path)endendend@@ -146,7 +146,7 @@ describe OptimizedImage doexpect(File.size(tmp_path)).to be < 2300ensure- File.delete(tmp_path) if File.exists?(tmp_path)+ File.delete(tmp_path) if File.exist?(tmp_path)endendenddiff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex e6fe72fac57..579a0c61f23 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -425,7 +425,7 @@ enddef file_from_fixtures(filename, directory = "images")SpecSecureRandom.value ||= SecureRandom.hex- FileUtils.mkdir_p(file_from_fixtures_tmp_folder) unless Dir.exists?(file_from_fixtures_tmp_folder)+ FileUtils.mkdir_p(file_from_fixtures_tmp_folder) unless Dir.exist?(file_from_fixtures_tmp_folder)tmp_file_path = File.join(file_from_fixtures_tmp_folder, SecureRandom.hex << filename)FileUtils.cp("#{Rails.root}/spec/fixtures/#{directory}/#{filename}", tmp_file_path)File.new(tmp_file_path)diff --git a/spec/requests/admin/backups_controller_spec.rb b/spec/requests/admin/backups_controller_spec.rbindex 6e3c06ec492..673d42dee28 100644--- a/spec/requests/admin/backups_controller_spec.rb+++ b/spec/requests/admin/backups_controller_spec.rb@@ -37,7 +37,7 @@ RSpec.describe Admin::BackupsController doafter doDiscourse.redis.flushdb- @paths&.each { |path| File.delete(path) if File.exists?(path) }+ @paths&.each { |path| File.delete(path) if File.exist?(path) }@paths = nilend@@ -133,14 +133,14 @@ RSpec.describe Admin::BackupsController dobeginpath = backup_path(backup_filename)create_backup_files(backup_filename)- expect(File.exists?(path)).to eq(true)+ expect(File.exist?(path)).to eq(true)expect dodelete "/admin/backups/#{backup_filename}.json"end.to change { UserHistory.where(action: UserHistory.actions[:backup_destroy]).count }.by(1)expect(response.status).to eq(200)- expect(File.exists?(path)).to eq(false)+ expect(File.exist?(path)).to eq(false)endenddiff --git a/spec/requests/api/backups_spec.rb b/spec/requests/api/backups_spec.rbindex 27317a41f11..867a840d7a0 100644--- a/spec/requests/api/backups_spec.rb+++ b/spec/requests/api/backups_spec.rb@@ -29,7 +29,7 @@ describe 'backups' doafter doDiscourse.redis.flushdb- @paths&.each { |path| File.delete(path) if File.exists?(path) }+ @paths&.each { |path| File.delete(path) if File.exist?(path) }@paths = nilend