Commit 4af1c7f1 authored by Doug MacEachern's avatar Doug MacEachern

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.
parent 3f5a02cf
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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment