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 74 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 34 def file_for_provider logger.trace("#{@new_resource} checking for changes") if current_resource_matches_target_checksum? logger.trace("#{@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
Given a source uri, return a Tempfile, or a File
that acts like a Tempfile (close! method)
# File lib/chef/provider/remote_file/content.rb, line 70 def grab_file_from_uri(uri) Chef::Provider::RemoteFile::Fetcher.for_resource(uri, @new_resource, @current_resource).fetch end
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 47 def try_multiple_sources(sources) sources = sources.dup source = sources.shift begin uri = if Chef::Provider::RemoteFile::Fetcher.network_share?(source) source else as_uri(source) end raw_file = grab_file_from_uri(uri) rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPClientException, Net::HTTPFatalError, Net::FTPError, Errno::ETIMEDOUT => e logger.warn("#{@new_resource} cannot be downloaded from #{source}: #{e}") if source = sources.shift logger.info("#{@new_resource} trying to download from another mirror") retry else raise e end end raw_file end