Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

replace deprecated File.exists?

ulfertscb63949c580e
diff --git a/app/workers/backup_job.rb b/app/workers/backup_job.rb
index 26755019491..d4f74ba0c16 100644
--- a/app/workers/backup_job.rb
+++ b/app/workers/backup_job.rb
@@ -114,7 +114,7 @@ class BackupJob < ::ApplicationJob
def remove_files!(*files)
Array(files).each do |file|
- FileUtils.rm file if File.exists? file
+ FileUtils.rm file if File.exist? file
end
end
diff --git a/config/application.rb b/config/application.rb
index d9a8c73f0dd..e2839d4fe24 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -176,7 +176,7 @@ module OpenProject
# Load any local configuration that is kept out of source control
# (e.g. patches).
- if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
+ if File.exist?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end
diff --git a/config/boot.rb b/config/boot.rb
index ad889d1a77b..cf39b6fb28a 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -32,7 +32,7 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
# Load any local boot extras that is kept out of source control
# (e.g., silencing of deprecations)
-if File.exists?(File.join(File.dirname(__FILE__), 'additional_boot.rb'))
+if File.exist?(File.join(File.dirname(__FILE__), 'additional_boot.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_boot.rb'))
end
diff --git a/lib/open_project/content_type_detector.rb b/lib/open_project/content_type_detector.rb
index f6ecc640c14..55af937b3cf 100644
--- a/lib/open_project/content_type_detector.rb
+++ b/lib/open_project/content_type_detector.rb
@@ -105,7 +105,7 @@ module OpenProject
private
def empty_file?
- File.exists?(@filename) && File.size(@filename) == 0
+ File.exist?(@filename) && File.size(@filename) == 0
end
alias :empty? :empty_file?
diff --git a/lib/open_project/version.rb b/lib/open_project/version.rb
index 7730989e11e..af5e84d3f35 100644
--- a/lib/open_project/version.rb
+++ b/lib/open_project/version.rb
@@ -60,7 +60,7 @@ module OpenProject
def product_version
cached_or_block(:@product_version) do
path = Rails.root.join('config', 'PRODUCT_VERSION')
- if File.exists? path
+ if File.exist? path
File.read(path)
end
end
@@ -69,7 +69,7 @@ module OpenProject
def core_version
cached_or_block(:@core_version) do
path = Rails.root.join('config', 'CORE_VERSION')
- if File.exists? path
+ if File.exist? path
File.read(path)
end
end
@@ -96,7 +96,7 @@ module OpenProject
def release_date_from_file
cached_or_block(:@release_date_from_file) do
path = Rails.root.join('config', 'RELEASE_DATE')
- if File.exists? path
+ if File.exist? path
s = File.read(path)
Date.parse(s)
end
diff --git a/lib/tasks/attachments.rake b/lib/tasks/attachments.rake
index ad68151f468..794bffc260e 100644
--- a/lib/tasks/attachments.rake
+++ b/lib/tasks/attachments.rake
@@ -83,7 +83,7 @@ namespace :attachments do
# file in the target location.
def self.store!(attachment)
return nil unless attachment.attributes['file'].present? &&
- File.exists?(attachment.file.path)
+ File.exist?(attachment.file.path)
new.tap do |target|
target.id = attachment.id
diff --git a/lib/tasks/copyright.rake b/lib/tasks/copyright.rake
index 374c7330b4f..ead2e8ef683 100644
--- a/lib/tasks/copyright.rake
+++ b/lib/tasks/copyright.rake
@@ -53,9 +53,9 @@ namespace :copyright do
def copyright_file(options = {})
path = 'COPYRIGHT_short'
if options[:path]
- path = File.join(options[:path], 'COPYRIGHT_short') if File.exists?(File.join(options[:path],
+ path = File.join(options[:path], 'COPYRIGHT_short') if File.exist?(File.join(options[:path],
'COPYRIGHT_short'))
- path = File.join(options[:path], 'COPYRIGHT_short.md') if File.exists?(File.join(options[:path],
+ path = File.join(options[:path], 'COPYRIGHT_short.md') if File.exist?(File.join(options[:path],
'COPYRIGHT_short.md'))
end
path
diff --git a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
index ef128502b0e..b6fcd8298c3 100644
--- a/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
+++ b/modules/bim/app/contracts/bim/ifc_models/base_contract.rb
@@ -80,7 +80,7 @@ module Bim
# For local uploads the file must remain to be copied later to its final (local) destination from the cache.
return unless OpenProject::Configuration.direct_uploads?
- FileUtils.rm file_path if File.exists? file_path
+ FileUtils.rm file_path if File.exist? file_path
end
def uploader_is_ifc_attachment_author
diff --git a/modules/bim/spec/services/ifc_models/view_conversion_service_spec.rb b/modules/bim/spec/services/ifc_models/view_conversion_service_spec.rb
index 26896672267..e51c3f1a78a 100644
--- a/modules/bim/spec/services/ifc_models/view_conversion_service_spec.rb
+++ b/modules/bim/spec/services/ifc_models/view_conversion_service_spec.rb
@@ -94,7 +94,7 @@ describe Bim::IfcModels::ViewConverterService do
# mocking all convert! calls so they do nothing but create an empty dummy result file
allow(subject).to receive(:convert!) do |source_file, ext|
- expect(File.exists?(source_file)).to be_truthy, "Expected #{source_file} to exist."
+ expect(File.exist?(source_file)).to be_truthy, "Expected #{source_file} to exist."
target_file_path = source_file.sub ext_regex, "." + ext
diff --git a/spec/lib/open_project/storage_spec.rb b/spec/lib/open_project/storage_spec.rb
index 5d357725e4f..d913bca8d9e 100644
--- a/spec/lib/open_project/storage_spec.rb
+++ b/spec/lib/open_project/storage_spec.rb
@@ -59,7 +59,7 @@ describe OpenProject::Storage do
end
it 'should contain one fs entry' do
- expect(File.exists?(tmpdir)).to be true
+ expect(File.exist?(tmpdir)).to be true
expect(subject.length).to be == 1
entry = subject.values.first
diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb
index 30c678d06f7..07eb4e312bf 100644
--- a/spec/models/attachment_spec.rb
+++ b/spec/models/attachment_spec.rb
@@ -150,7 +150,7 @@ describe Attachment, type: :model do
describe 'create' do
it('creates a jpg file called test') do
- expect(File.exists?(attachment.diskfile.path)).to eq true
+ expect(File.exist?(attachment.diskfile.path)).to eq true
end
it('has the content type "image/jpeg"') do
@@ -191,7 +191,7 @@ describe Attachment, type: :model do
before do
attachment.save!
- expect(File.exists?(attachment.file.path)).to eq true
+ expect(File.exist?(attachment.file.path)).to eq true
attachment.destroy
attachment.run_callbacks(:commit)
@@ -200,7 +200,7 @@ describe Attachment, type: :model do
end
it "deletes the attachment's file" do
- expect(File.exists?(attachment.file.path)).to eq false
+ expect(File.exist?(attachment.file.path)).to eq false
end
end
diff --git a/spec/support/rspec_disabled_specs.rb b/spec/support/rspec_disabled_specs.rb
index 174ae88a737..06d8cc993e5 100644
--- a/spec/support/rspec_disabled_specs.rb
+++ b/spec/support/rspec_disabled_specs.rb
@@ -9,7 +9,7 @@ Rails.application.config.plugins_to_test_paths.each do |dir|
['disabled_specs.rb', 'disable_specs.rb', 'config_spec_helper.rb'].each do |file_name|
file = File.join(dir, 'spec', file_name)
- if File.exists?(file)
+ if File.exist?(file)
puts "Loading #{file}"
require file
end