Commit 55802746 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox,vmware: retry removing output dir if fails

parent 8ac03e48
...@@ -17,6 +17,8 @@ BUG FIXES: ...@@ -17,6 +17,8 @@ BUG FIXES:
* builder/virtualbox,vmware: relative paths work properly as URL * builder/virtualbox,vmware: relative paths work properly as URL
configurations. [GH-215] configurations. [GH-215]
* builder/virtualbox,vmware: fix race condition in deleting the output
directory on Windows by retrying.
## 0.2.1 (July 26, 2013) ## 0.2.1 (July 26, 2013)
......
...@@ -3,7 +3,9 @@ package virtualbox ...@@ -3,7 +3,9 @@ package virtualbox
import ( import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
"os" "os"
"time"
) )
type stepPrepareOutputDir struct{} type stepPrepareOutputDir struct{}
...@@ -34,6 +36,14 @@ func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) { ...@@ -34,6 +36,14 @@ func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) {
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
ui.Say("Deleting output directory...") ui.Say("Deleting output directory...")
os.RemoveAll(config.OutputDir) for i := 0; i < 5; i++ {
err := os.RemoveAll(config.OutputDir)
if err == nil {
break
}
log.Printf("Error removing output dir: %s", err)
time.Sleep(2 * time.Second)
}
} }
} }
...@@ -3,7 +3,9 @@ package vmware ...@@ -3,7 +3,9 @@ package vmware
import ( import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"log"
"os" "os"
"time"
) )
type stepPrepareOutputDir struct{} type stepPrepareOutputDir struct{}
...@@ -34,6 +36,15 @@ func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) { ...@@ -34,6 +36,15 @@ func (stepPrepareOutputDir) Cleanup(state map[string]interface{}) {
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
ui.Say("Deleting output directory...") ui.Say("Deleting output directory...")
os.RemoveAll(config.OutputDir)
for i := 0; i < 5; i++ {
err := os.RemoveAll(config.OutputDir)
if err == nil {
break
}
log.Printf("Error removing output dir: %s", err)
time.Sleep(2 * time.Second)
}
} }
} }
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