diff options
author | Adam Jacob <adam@hjksolutions.com> | 2008-08-17 12:45:51 -0700 |
---|---|---|
committer | Adam Jacob <adam@hjksolutions.com> | 2008-08-17 12:45:51 -0700 |
commit | 433d9e5e80d5cbaee785cae6d89764f945366174 (patch) | |
tree | 849ea2700c9356ad32db9fe10bef943a638cdf99 /lib | |
parent | 14b3ad55773ee01436dc84b8db0d472e8b795167 (diff) | |
download | chef-433d9e5e80d5cbaee785cae6d89764f945366174.tar.gz |
Updating the remote_file spec, simplifying remote_file a bit
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/remote_file.rb | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb index 515f7fc5ab..cc0812346e 100644 --- a/lib/chef/provider/remote_file.rb +++ b/lib/chef/provider/remote_file.rb @@ -48,37 +48,31 @@ class Chef begin raw_file = r.get_rest(url, true) rescue Net::HTTPRetriableError => e - if e.to_s =~ /304 "Not Modified"/ + if e.response.kind_of?(Net::HTTPNotModified) Chef::Log.debug("File #{path} is unchanged") - return + return false else raise e end end - - update = false - if ::File.exists?(path) - raw_file_checksum = self.checksum(raw_file.path) - if raw_file_checksum != current_checksum - Chef::Log.debug("#{path} changed from #{current_checksum} to #{raw_file_checksum}") - Chef::Log.info("Updating file for #{@new_resource} at #{path}") - update = true - end + raw_file_checksum = self.checksum(raw_file.path) + + if ::File.exists?(path) + Chef::Log.debug("#{path} changed from #{current_checksum} to #{raw_file_checksum}") + Chef::Log.info("Updating file for #{@new_resource} at #{path}") else Chef::Log.info("Creating file for #{@new_resource} at #{path}") - update = true - end - - if update - backup(path) - FileUtils.cp(raw_file.path, path) - @new_resource.updated = true end + + backup(path) + FileUtils.cp(raw_file.path, path) + @new_resource.updated = true set_owner if @new_resource.owner != nil set_group if @new_resource.group != nil set_mode if @new_resource.mode != nil + return true end end |