builder/vmware: Double check that OutputDirectory does not already exist

The initial check in Builder.Prepare does not use the OutputDir interface.
stepPrepareOutputDir also checks if OutputDir exists, error out there unless
using -force so we get the same behavior when RemoteType is esx5.
This commit is contained in:
Doug MacEachern 2013-11-12 13:11:02 -08:00
parent 3f5a02cf2a
commit 4af1c7f1b2
1 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package vmware
import (
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"log"
@ -24,9 +25,14 @@ func (s *stepPrepareOutputDir) Run(state multistep.StateBag) multistep.StepActio
return multistep.ActionHalt
}
if exists && config.PackerForce {
ui.Say("Deleting previous output directory...")
dir.RemoveAll()
if exists {
if config.PackerForce {
ui.Say("Deleting previous output directory...")
dir.RemoveAll()
} else {
state.Put("error", fmt.Errorf("Output directory '%s' already exists.", config.OutputDir))
return multistep.ActionHalt
}
}
if err := dir.MkdirAll(); err != nil {