diff --git a/lib/vagrant/actions/vm/package.rb b/lib/vagrant/actions/vm/package.rb index b5d6ea9a9..f4f47de2d 100644 --- a/lib/vagrant/actions/vm/package.rb +++ b/lib/vagrant/actions/vm/package.rb @@ -10,6 +10,8 @@ module Vagrant end def prepare + raise ActionException.new(:box_file_exists, :output_file => tar_path) if File.exist?(tar_path) + # Verify the existance of all the additional files, if any include_files.each do |file| raise ActionException.new(:package_include_file_doesnt_exist, :filename => file) unless File.exists?(file) diff --git a/templates/strings.yml b/templates/strings.yml index 6f279d477..cb5cabf06 100644 --- a/templates/strings.yml +++ b/templates/strings.yml @@ -70,6 +70,12 @@ A box with the name '<%= box_name %>' already exists, please use another name or use `vagrant box remove <%= box_name %>` :box_download_unknown_type: |- Unknown URI type for box download. +:box_file_exists: |- + The specified output file for packaging already exists. Please move + the file or modify the output filename parameter then try to package + again. + + Specified output file: <%= output_file %> :box_remove_doesnt_exist: |- The box you're attempting to remove does not exist! :box_specified_doesnt_exist: |- diff --git a/test/vagrant/actions/vm/package_test.rb b/test/vagrant/actions/vm/package_test.rb index 35fd64529..e3b4c5daa 100644 --- a/test/vagrant/actions/vm/package_test.rb +++ b/test/vagrant/actions/vm/package_test.rb @@ -226,6 +226,11 @@ class PackageActionTest < Test::Unit::TestCase @action.prepare end + should "raise an exception if the output file already exists" do + File.expects(:exist?).with(@action.tar_path).returns(false) + assert_raises(Vagrant::Actions::ActionException) { @action.prepare } + end + should "raise an exception when an include file does not exist" do File.expects(:exists?).once.returns(false) assert_raises(Vagrant::Actions::ActionException) { @action.prepare } diff --git a/vagrant.gemspec b/vagrant.gemspec index a21c668c8..2b53dfbaf 100644 --- a/vagrant.gemspec +++ b/vagrant.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.authors = ["Mitchell Hashimoto", "John Bender"] - s.date = %q{2010-06-24} + s.date = %q{2010-06-29} s.default_executable = %q{vagrant} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]