Skip to content

Commit

Permalink
Fixes multiple files behavior in files rootfs
Browse files Browse the repository at this point in the history
Some files may be left uncopied to the VM when there are multiple
files in the .minikube/files directory as the code misinterprets
the last parent dir as parent dirs for all files, which results
some files with the same name were not copied.

This patch fixes the behavior.
  • Loading branch information
laozc committed Feb 10, 2019
1 parent 6e1b9d0 commit 0c1d3f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,15 @@ func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) erro
return errors.Wrapf(err, "checking if %s is directory", hostpath)
}
if !isDir {
if vmpath == "" {
vmdir := vmpath
if vmdir == "" {
rPath, err := filepath.Rel(basedir, hostpath)
if err != nil {
return errors.Wrap(err, "generating relative path")
}
rPath = filepath.Dir(rPath)
rPath = filepath.ToSlash(rPath)
vmpath = path.Join("/", rPath)
vmdir = path.Join("/", rPath)
}
permString := fmt.Sprintf("%o", info.Mode().Perm())
// The conversion will strip the leading 0 if present, so add it back
Expand All @@ -318,7 +319,7 @@ func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) erro
permString = fmt.Sprintf("0%s", permString)
}

f, err := NewFileAsset(hostpath, vmpath, filepath.Base(hostpath), permString)
f, err := NewFileAsset(hostpath, vmdir, filepath.Base(hostpath), permString)
if err != nil {
return errors.Wrapf(err, "creating file asset for %s", hostpath)
}
Expand Down

0 comments on commit 0c1d3f2

Please sign in to comment.