diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/cookbook_file.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/directory.rb | 7 | ||||
-rw-r--r-- | lib/chef/provider/file.rb | 28 | ||||
-rw-r--r-- | lib/chef/provider/remote_file.rb | 8 | ||||
-rw-r--r-- | lib/chef/provider/template.rb | 8 |
5 files changed, 40 insertions, 19 deletions
diff --git a/lib/chef/provider/cookbook_file.rb b/lib/chef/provider/cookbook_file.rb index d59950780f..18af70d415 100644 --- a/lib/chef/provider/cookbook_file.rb +++ b/lib/chef/provider/cookbook_file.rb @@ -38,6 +38,14 @@ class Chef super end + private + + def managing_content? + return true if @new_resource.checksum + return true if !@new_resource.source.nil? && @action != :create_if_missing + false + end + end end end diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb index e3d2b89f2e..067737b9d4 100644 --- a/lib/chef/provider/directory.rb +++ b/lib/chef/provider/directory.rb @@ -123,6 +123,13 @@ class Chef end end end + + private + + def managing_content? + false + end + end end end diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 12fa97e334..b2127d7c87 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -1,4 +1,4 @@ - +# # Author:: Adam Jacob (<adam@opscode.com>) # Author:: Lamont Granquist (<lamont@opscode.com>) # Copyright:: Copyright (c) 2008-2013 Opscode, Inc. @@ -75,7 +75,7 @@ class Chef @current_resource ||= Chef::Resource::File.new(@new_resource.name) @current_resource.path(@new_resource.path) if ::File.exists?(@current_resource.path) && ::File.file?(::File.realpath(@current_resource.path)) - if should_do_checksum? + if managing_content? Chef::Log.debug("#{@new_resource} checksumming file at #{@new_resource.path}.") @current_resource.checksum(checksum(@current_resource.path)) end @@ -160,22 +160,12 @@ class Chef private - def should_do_checksum? - if @current_resource.respond_to?(:checksum) - case - when @new_resource.checksum - return true - when @action == :create_if_missing - return false - when @new_resource.respond_to?(:source) - return true - when @new_resource.content.nil? - return false - else - return true - end - end - # We may be a File::Provider::Directory + # What to check in this resource to see if we're going to be actively managing + # content (for things like doing checksums in load_current_resource). Expected to + # be overridden in subclasses. + def managing_content? + return true if @new_resource.checksum + return true if !@new_resource.content.nil? && @action != :create_if_missing false end @@ -350,7 +340,7 @@ class Chef do_backup unless file_created? deployment_strategy.deploy(tempfile.path, ::File.realpath(@new_resource.path)) Chef::Log.info("#{@new_resource} updated file contents #{@new_resource.path}") - if should_do_checksum? + if managing_content? @new_resource.checksum(checksum(@new_resource.path)) # for reporting end end diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb index d62f4aa13c..ed99c0bb84 100644 --- a/lib/chef/provider/remote_file.rb +++ b/lib/chef/provider/remote_file.rb @@ -39,6 +39,14 @@ class Chef super end + private + + def managing_content? + return true if @new_resource.checksum + return true if !@new_resource.source.nil? && @action != :create_if_missing + false + end + end end end diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb index 217f9e56ec..555f4f14f0 100644 --- a/lib/chef/provider/template.rb +++ b/lib/chef/provider/template.rb @@ -52,6 +52,14 @@ class Chef end end + private + + def managing_content? + return true if @new_resource.checksum + return true if !@new_resource.source.nil? && @action != :create_if_missing + false + end + end end end |