Skip to content

Commit

Permalink
overlay: create the merged path only if it does not exist
Browse files Browse the repository at this point in the history
follow-up for ccb70a7

more information here: containers#1827 (comment)

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Mar 11, 2024
1 parent 853cc6a commit 09b8195
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -1666,9 +1666,12 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
}

mergedDir := path.Join(dir, "merged")
// Create the driver merged dir
if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
// attempt to create the merged dir only if it doesn't exist.
if _, err := os.Stat(mergedDir); err != nil {
// Create the driver merged dir
if err := idtools.MkdirAs(mergedDir, 0o700, rootUID, rootGID); err != nil && !os.IsExist(err) {
return "", err
}
}
if count := d.ctr.Increment(mergedDir); count > 1 {
return mergedDir, nil
Expand Down

0 comments on commit 09b8195

Please sign in to comment.