提交 19695856 编写于 作者: T Thomas Stromberg

Skip mkdir if there is no work to be done

上级 1f346e43
......@@ -31,6 +31,15 @@ import (
"k8s.io/minikube/pkg/minikube/vmpath"
)
// guaranteed are directories we don't need to attempt recreation of
var guaranteed = map[string]bool{
"/": true,
"": true,
"/etc": true,
"/var": true,
"/tmp": true,
}
// syncLocalAssets syncs files from MINIKUBE_HOME into the cluster
func syncLocalAssets(cr command.Runner) error {
fs, err := localAssets()
......@@ -38,20 +47,30 @@ func syncLocalAssets(cr command.Runner) error {
return err
}
dirs := map[string]bool{}
for _, f := range fs {
dirs[f.GetTargetDir()] = true
if len(fs) == 0 {
return nil
}
args := []string{"mkdir", "-p"}
for k := range dirs {
args = append(args, k)
// Deduplicate the list of directories to create
seen := map[string]bool{}
create := []string{}
for _, f := range fs {
dir := f.GetTargetDir()
if guaranteed[dir] || seen[dir] {
continue
}
create = append(create, dir)
}
cmd := exec.Command("sudo", args...)
if _, err := cr.RunCmd(cmd); err != nil {
return err
// Create directories that are not guaranteed to exist
if len(create) > 0 {
args := append([]string{"mkdir", "-p"}, create...)
if _, err := cr.RunCmd(exec.Command("sudo", args...)); err != nil {
return err
}
}
// Copy the files into place
for _, f := range fs {
err := cr.Copy(f)
if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册