class Chef::Provider::RemoteFile::Content
Private Instance Methods
current_resource_matches_target_checksum?()
click to toggle source
# File lib/chef/provider/remote_file/content.rb, line 68 def current_resource_matches_target_checksum? @new_resource.checksum && @current_resource.checksum && @current_resource.checksum =~ /^#{Regexp.escape(@new_resource.checksum)}/ end
file_for_provider()
click to toggle source
# File lib/chef/provider/remote_file/content.rb, line 32 def file_for_provider Chef::Log.debug("#{@new_resource} checking for changes") if current_resource_matches_target_checksum? Chef::Log.debug("#{@new_resource} checksum matches target checksum (#{@new_resource.checksum}) - not updating") else sources = @new_resource.source raw_file = try_multiple_sources(sources) end raw_file end
grab_file_from_uri(uri)
click to toggle source
try_multiple_sources(sources)
click to toggle source
Given an array of source uris, iterate through them until one does not fail
# File lib/chef/provider/remote_file/content.rb, line 45 def try_multiple_sources(sources) sources = sources.dup source = sources.shift begin uri = URI.parse(source) raw_file = grab_file_from_uri(uri) rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPServerException, Net::HTTPFatalError, Net::FTPError => e Chef::Log.warn("#{@new_resource} cannot be downloaded from #{source}: #{e.to_s}") if source = sources.shift Chef::Log.info("#{@new_resource} trying to download from another mirror") retry else raise e end end raw_file end