summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2021-05-02 11:08:12 -0700
committerTim Smith <tsmith@chef.io>2021-05-02 11:15:29 -0700
commit5c69e504d38266e365344d32336606d8609732a3 (patch)
tree66f4a8326b79e727a353e5617e5587e55b44ece2
parent90c3e7d63647278c081fd67716329f1df4c7828d (diff)
downloadchef-5c69e504d38266e365344d32336606d8609732a3.tar.gz
Resolve File.exists? in directory provider
One more down Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/directory.rb12
-rw-r--r--spec/unit/chef_fs/file_system/repository/directory_spec.rb2
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb
index 555340d91e..6a20556ccd 100644
--- a/lib/chef/provider/directory.rb
+++ b/lib/chef/provider/directory.rb
@@ -32,7 +32,7 @@ class Chef
def load_current_resource
@current_resource = Chef::Resource::Directory.new(new_resource.name)
current_resource.path(new_resource.path)
- if ::File.exists?(current_resource.path) && @action != :create_if_missing
+ if ::File.exist?(current_resource.path) && @action != :create_if_missing
load_resource_attributes_from_file(current_resource)
end
current_resource
@@ -73,7 +73,7 @@ class Chef
# make sure we have write permissions to that directory
is_parent_writable = lambda do |base_dir|
base_dir = ::File.dirname(base_dir)
- if ::File.exists?(base_dir)
+ if ::File.exist?(base_dir)
if Chef::FileAccessControl.writable?(base_dir)
true
elsif Chef::Util::PathHelper.is_sip_path?(base_dir, node)
@@ -89,7 +89,7 @@ class Chef
else
# in why run mode & parent directory does not exist no permissions check is required
# If not in why run, permissions must be valid and we rely on prior assertion that dir exists
- if !whyrun_mode? || ::File.exists?(parent_directory)
+ if !whyrun_mode? || ::File.exist?(parent_directory)
if Chef::FileAccessControl.writable?(parent_directory)
true
elsif Chef::Util::PathHelper.is_sip_path?(parent_directory, node)
@@ -108,7 +108,7 @@ class Chef
requirements.assert(:delete) do |a|
a.assertion do
- if ::File.exists?(new_resource.path)
+ if ::File.exist?(new_resource.path)
::File.directory?(new_resource.path) && Chef::FileAccessControl.writable?(new_resource.path)
else
true
@@ -122,7 +122,7 @@ class Chef
end
action :create do
- unless ::File.exists?(new_resource.path)
+ unless ::File.exist?(new_resource.path)
converge_by("create new directory #{new_resource.path}") do
if new_resource.recursive == true
::FileUtils.mkdir_p(new_resource.path)
@@ -138,7 +138,7 @@ class Chef
end
action :delete do
- if ::File.exists?(new_resource.path)
+ if ::File.exist?(new_resource.path)
converge_by("delete existing directory #{new_resource.path}") do
if new_resource.recursive == true
# we don't use rm_rf here because it masks all errors, including
diff --git a/spec/unit/chef_fs/file_system/repository/directory_spec.rb b/spec/unit/chef_fs/file_system/repository/directory_spec.rb
index c8d71f976c..74cddcedb0 100644
--- a/spec/unit/chef_fs/file_system/repository/directory_spec.rb
+++ b/spec/unit/chef_fs/file_system/repository/directory_spec.rb
@@ -64,7 +64,7 @@ describe Chef::ChefFS::FileSystem::Repository::Directory do
end
let(:file_double) do
- double(TestFile, create: true, exists?: false)
+ double(TestFile, create: true, exist?: false, exists?: false)
end
context "#make_child_entry" do