diff options
Diffstat (limited to 'chef/lib/chef/provider/remote_file.rb')
-rw-r--r-- | chef/lib/chef/provider/remote_file.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/chef/lib/chef/provider/remote_file.rb b/chef/lib/chef/provider/remote_file.rb index 9b5c9db04a..247549ed95 100644 --- a/chef/lib/chef/provider/remote_file.rb +++ b/chef/lib/chef/provider/remote_file.rb @@ -55,23 +55,30 @@ class Chef get_from_local_cookbook(source) # If the file exists + Chef::Log.debug "#{@new_resource}: Checking for file existence of #{@new_resource.path}" if ::File.exists?(@new_resource.path) # And it matches the checksum of the raw file @new_resource.checksum(self.checksum(raw_file.path)) + Chef::Log.debug "#{@new_resource}: File exists at #{@new_resource.path}" + Chef::Log.debug "#{@new_resource}: Target checksum: #{@current_resource.checksum}" + Chef::Log.debug "#{@new_resource}: Source checksum: #{@new_resource.checksum}" if @new_resource.checksum != @current_resource.checksum # Updating target file, let's perform a backup! - Chef::Log.debug("#{@new_resource} changed from #{@current_resource.checksum} to #{@new_resource.checksum}") - Chef::Log.info("Updating #{@new_resource} at #{@new_resource.path}") - backup(@new_resource.path) + Chef::Log.debug "#{@new_resource}: checksum changed from #{@current_resource.checksum} to #{@new_resource.checksum}" + Chef::Log.info "#{@new_resource}: Updating #{@new_resource.path}" + backup @new_resource.path + FileUtils.cp raw_file.path, @new_resource.path + @new_resource.updated = true + else + Chef::Log.debug "#{@new_resource}: Target and Source checksums are the same, taking no action" end else # We're creating a new file - Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}") + Chef::Log.info "#{@new_resource}: Creating #{@new_resource.path}" + FileUtils.cp raw_file.path, @new_resource.path + @new_resource.updated = true end - FileUtils.cp(raw_file.path, @new_resource.path) - @new_resource.updated = true - # We're done with the file, so make sure to close it if it was open. raw_file.close unless raw_file.closed? rescue Net::HTTPRetriableError => e |