class CookbookOmnifetch::ArtifactserverLocation

def install

Returns:
  • (void) -
def install
  FileUtils.mkdir_p(cache_root) unless cache_root.exist?
  http = http_client(uri)
  http.streaming_request(nil) do |tempfile|
    tempfile.close
    FileUtils.mv(tempfile.path, cache_path)
  end
  FileUtils.mkdir_p(staging_root) unless staging_root.exist?
  Dir.mktmpdir(nil, staging_root) do |staging_dir|
    Zlib::GzipReader.open(cache_path) do |gz_file|
      tar = Archive::Tar::Minitar::Input.new(gz_file)
      tar.each do |e|
        tar.extract_entry(staging_dir, e)
      end
    end
    staged_cookbook_path = File.join(staging_dir, cookbook_name)
    validate_cached!(staged_cookbook_path)
    FileUtils.mv(staged_cookbook_path, install_path)
  end
end