From c0121ac08e0a38a0a071b1371836dd3e3ec02a51 Mon Sep 17 00:00:00 2001 From: John Bender Date: Fri, 30 Jul 2010 18:16:23 -0700 Subject: [PATCH] box download action switched to warden rescue --- lib/vagrant/action/box/download.rb | 6 ++---- test/vagrant/action/box/download_test.rb | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/action/box/download.rb b/lib/vagrant/action/box/download.rb index 803ad89d0..2657a7e75 100644 --- a/lib/vagrant/action/box/download.rb +++ b/lib/vagrant/action/box/download.rb @@ -22,8 +22,6 @@ module Vagrant return if env.error? @app.call(@env) - - cleanup end def instantiate_downloader @@ -50,9 +48,9 @@ module Vagrant end end - def cleanup + def rescue(env) if temp_path && File.exist?(temp_path) - @env.logger.info "Cleaning up downloaded box..." + env.logger.info "Cleaning up downloaded box..." File.unlink(temp_path) end end diff --git a/test/vagrant/action/box/download_test.rb b/test/vagrant/action/box/download_test.rb index f2388567e..913ac17a2 100644 --- a/test/vagrant/action/box/download_test.rb +++ b/test/vagrant/action/box/download_test.rb @@ -32,7 +32,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase @instance.expects(:instantiate_downloader).in_sequence(seq).returns(true) @instance.expects(:download).in_sequence(seq) @app.expects(:call).with(@env).in_sequence(seq) - @instance.expects(:cleanup).in_sequence(seq) @instance.call(@env) end @@ -42,7 +41,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase @instance.expects(:instantiate_downloader).in_sequence(seq).returns(false) @instance.expects(:download).never @app.expects(:call).with(@env).never - @instance.expects(:cleanup).never @instance.call(@env) end end @@ -115,13 +113,13 @@ class DownloadBoxActionTest < Test::Unit::TestCase should "delete the temporary file if it exists" do File.expects(:unlink).with(@temp_path).once - @instance.cleanup + @instance.rescue(@env) end should "not delete anything if it doesn't exist" do File.stubs(:exist?).returns(false) File.expects(:unlink).never - @instance.cleanup + @instance.rescue(@env) end end