class Chef::Provider::Download
Public Class Methods
# File lib/garcon/chef/provider/download.rb, line 93 def initialize(name, run_context = nil) super @resource_name = :download @provider = Chef::Provider::Download @ready = AtomicBoolean.new(installed?('aria2c')) @lock = ReadWriteLock.new make_ready unless ready? poll(300) { ready? } end
Public Instance Methods
Default, download the specified source file if it does not exist. If a file already exists (but does not match), use to update that file to match.
@return [undefined]
@api public
# File lib/garcon/chef/provider/download.rb, line 155 def action_create if @current_resource.exist? && !access_controls.requires_changes? Chef::Log.debug "#{r.path} already exists - nothing to do" elsif @current_resource.exist? && access_controls.requires_changes? converge_by(access_controls.describe_changes) do access_controls.set_all end r.updated_by_last_action(true) else converge_by "Download #{r.path}" do backup unless ::File.symlink?(r.path) do_download end do_acl_changes load_resource_attributes_from_file(r) r.updated_by_last_action(true) load_new_resource_state r.exist = true end end
Use to delete a file.
@return [undefined]
@api public
# File lib/garcon/chef/provider/download.rb, line 185 def action_delete if @current_resource.exist? converge_by "Delete #{r.path}" do backup unless ::File.symlink?(r.path) ::File.delete(r.path) end r.updated_by_last_action(true) load_new_resource_state r.exist = false else Chef::Log.debug "#{r.path} does not exists - nothing to do" end end
Use to touch a file. This updates the access (atime) and file modification (mtime) times for a file. (This action may be used with this resource, but is typically only used with the file resource.)
@return [undefined]
@api public
# File lib/garcon/chef/provider/download.rb, line 206 def action_touch if @current_resource.exist? converge_by "Update utime on #{r.path}" do time = Time.now ::File.utime(time, time, r.path) end r.updated_by_last_action(true) load_new_resource_state r.exist = true else Chef::Log.debug "#{r.path} does not exists - nothing to do" end end
Load and return the current resource.
@return [Chef::Provider::Download]
@api private
# File lib/garcon/chef/provider/download.rb, line 131 def load_current_resource @current_resource ||= Chef::Resource::Download.new(r.name) @current_resource.path(r.path) if ::File.exist?(@current_resource.path) @current_resource.checksum(checksum(@current_resource.path)) if @current_resource.checksum == r.checksum @current_resource.exist = true else @current_resource.exist = false end else @current_resource.exist = false end @current_resource end
Reload the resource state when something changes
@return [undefined]
@api private
# File lib/garcon/chef/provider/download.rb, line 122 def load_new_resource_state r.exist = @current_resource.exist if r.exist.nil? end
Implementation components should follow symlinks when managing access control (e.g., use chmod instead of lchmod even if the path we’re managing is a symlink).
# File lib/garcon/chef/provider/download.rb, line 224 def manage_symlink_access? false end
Boolean
indicating if WhyRun is supported by this provider
@return [TrueClass, FalseClass]
@api private
# File lib/garcon/chef/provider/download.rb, line 113 def whyrun_supported? true end