Commit 54e081d5 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: only remove output dir after check

parent 897888fd
...@@ -17,6 +17,8 @@ import ( ...@@ -17,6 +17,8 @@ import (
type StepOutputDir struct { type StepOutputDir struct {
Force bool Force bool
Path string Path string
cleanup bool
} }
func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction {
...@@ -36,6 +38,9 @@ func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { ...@@ -36,6 +38,9 @@ func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction {
os.RemoveAll(s.Path) os.RemoveAll(s.Path)
} }
// Enable cleanup
s.cleanup = true
// Create the directory // Create the directory
if err := os.MkdirAll(s.Path, 0755); err != nil { if err := os.MkdirAll(s.Path, 0755); err != nil {
state.Put("error", err) state.Put("error", err)
...@@ -56,6 +61,10 @@ func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { ...@@ -56,6 +61,10 @@ func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction {
} }
func (s *StepOutputDir) Cleanup(state multistep.StateBag) { func (s *StepOutputDir) Cleanup(state multistep.StateBag) {
if !s.cleanup {
return
}
_, cancelled := state.GetOk(multistep.StateCancelled) _, cancelled := state.GetOk(multistep.StateCancelled)
_, halted := state.GetOk(multistep.StateHalted) _, halted := state.GetOk(multistep.StateHalted)
......
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