Sha256: 04a031eeb92de49fa4009390e734fa0729c0f614b80e2bd6e764d14e6cb35cb5
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
module Vagrant class Action module Box class Download BASENAME = "box" include Util attr_reader :temp_path def initialize(app, env) @app = app @env = env @env["download.classes"] ||= [] @env["download.classes"] += [Downloaders::HTTP, Downloaders::File] @downloader = nil end def call(env) @env = env download if instantiate_downloader @app.call(@env) recover(env) # called in both cases to cleanup workspace end def instantiate_downloader @env["download.classes"].each do |klass| if klass.match?(@env["box"].uri) @env.ui.info I18n.t("vagrant.actions.box.download.with", :class => klass.to_s) @downloader = klass.new(@env) end end raise Errors::BoxDownloadUnknownType if !@downloader @downloader.prepare(@env["box"].uri) true end def download with_tempfile do |tempfile| download_to(tempfile) @temp_path = @env["download.temp_path"] = tempfile.path end end def recover(env) if temp_path && File.exist?(temp_path) env.ui.info I18n.t("vagrant.actions.box.download.cleaning") File.unlink(temp_path) end end def with_tempfile File.open(box_temp_path, Platform.tar_file_options) do |tempfile| yield tempfile end end def box_temp_path @env.env.tmp_path.join(BASENAME + Time.now.to_i.to_s) end def download_to(f) @env.ui.info I18n.t("vagrant.actions.box.download.copying") @downloader.download!(@env["box"].uri, f) end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
vagrantup-0.6.9 | lib/vagrant/action/box/download.rb |
vagrant-0.7.0.beta | lib/vagrant/action/box/download.rb |
vagrant-0.6.9 | lib/vagrant/action/box/download.rb |