From 5e0bce5876e88faeb8a4d272566d2627af4423db Mon Sep 17 00:00:00 2001 From: Joseph Chilcote Date: Tue, 12 May 2020 13:12:46 -0700 Subject: [PATCH] Replace all occurrences of File.exists? with File.exist? Summary: Every time I go to use `File.exist?` I think to myself, "Which is it, `File.exists?` or `File.exist?`," and I go do a big grep search to discover that it's.... both? Well, according to the [ruby docs](https://ruby-doc.org/core-2.2.0/File.html#exist-3F-method), `File.exists?` is deprecated. So as a gift to my future self who will be doing an big grep in the future, this diff will replace all instances of `File.exists?` with `File.exist?` in cpe_* cookbooks. Also, same thing for `Dir.exists?` => `Dir.exist?` Reviewed By: gbatye, steelcowboy Differential Revision: D21507238 fbshipit-source-id: 307533d148963088a84c0f5089ad708ba57a1239 --- itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb | 4 ++-- itchef/cookbooks/cpe_remote/resources/file.rb | 2 +- itchef/cookbooks/cpe_remote/resources/zip.rb | 4 ++-- itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb b/itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb index 5bd36c77..ddd886f7 100644 --- a/itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb +++ b/itchef/cookbooks/cpe_flatpak/libraries/flatpak_helpers.rb @@ -28,7 +28,7 @@ def flatpak_remotes_receipt_path end def flatpak_remotes_receipt - return [] unless ::File.exists?(flatpak_remotes_receipt_path) + return [] unless ::File.exist?(flatpak_remotes_receipt_path) Chef::JSONCompat.from_json(::File.read(flatpak_remotes_receipt_path)) rescue StandardError [] @@ -39,7 +39,7 @@ def flatpak_packages_receipt_path end def flatpak_packages_receipt - return [] unless ::File.exists?(flatpak_packages_receipt_path) + return [] unless ::File.exist?(flatpak_packages_receipt_path) Chef::JSONCompat.from_json(::File.read(flatpak_packages_receipt_path)) rescue StandardError [] diff --git a/itchef/cookbooks/cpe_remote/resources/file.rb b/itchef/cookbooks/cpe_remote/resources/file.rb index e0133255..7db690e5 100644 --- a/itchef/cookbooks/cpe_remote/resources/file.rb +++ b/itchef/cookbooks/cpe_remote/resources/file.rb @@ -46,7 +46,7 @@ load_current_value do |desired| # ~FC006 path = desired.path - if ::File.exists?(path) + if ::File.exist?(path) f_stat = ::File.stat(path) checksum_ondisk = Chef::Digester.checksum_for_file(path) checksum checksum_ondisk diff --git a/itchef/cookbooks/cpe_remote/resources/zip.rb b/itchef/cookbooks/cpe_remote/resources/zip.rb index d32016d8..4ace43a2 100644 --- a/itchef/cookbooks/cpe_remote/resources/zip.rb +++ b/itchef/cookbooks/cpe_remote/resources/zip.rb @@ -44,13 +44,13 @@ extra_loco = extract_location.delete(':') zip_path = ::File.join(chef_cache, 'remote_zip', extra_loco, zip_name) - if ::File.exists?(zip_path) + if ::File.exist?(zip_path) checksum_ondisk = Chef::Digester.checksum_for_file(zip_path) zip_checksum checksum_ondisk end extract_path = desired.extract_location - if ::File.exists?(extract_path) + if ::File.exist?(extract_path) f_stat = ::File.stat(extract_path) unless platform?('windows') owner ::Etc.getpwuid(f_stat.uid).name diff --git a/itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb b/itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb index 47f5c2eb..0a04f842 100644 --- a/itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb +++ b/itchef/cookbooks/cpe_symlinks/resources/cpe_symlinks.rb @@ -30,7 +30,7 @@ # Create symlinks on disk node['cpe_symlinks'].to_h.map.each do |target_dir, symlinks| symlinks.each do |target, source| - next unless ::File.exists?(source) + next unless ::File.exist?(source) link ::File.join(target_dir, target) do to source end