Skip to content

Commit

Permalink
If destination does not exists, do not throw error
Browse files Browse the repository at this point in the history
When using volume mounts, the destination directory will get
created if it does not exists. The current code blows up when
the destination directory did not exists.

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Jan 15, 2021
1 parent 0acbb37 commit d0d9cde
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ func mountHelper(contentDir, source, dest string, _, _ int, graphOptions []strin
workDir := filepath.Join(contentDir, "work")
upperDir := filepath.Join(contentDir, "upper")
st, err := os.Stat(dest)
if err != nil {
return mount, err
if err == nil {
if err := os.Chmod(upperDir, st.Mode()); err != nil {
return mount, err
}
}
if err := os.Chmod(upperDir, st.Mode()); err != nil {
if !os.IsNotExist(err) {
return mount, err
}
overlayOptions = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s,private", source, upperDir, workDir)
Expand Down

0 comments on commit d0d9cde

Please sign in to comment.