Skip to content

Commit

Permalink
Decide to use os.Mkdir when creating chain layer directories since …
Browse files Browse the repository at this point in the history
…the temporary directory should already exist. The temporary directory is the parent of the chain layer directories, so there is no need to use `os.MkdirAll` as there will be no intermediate directories.

PiperOrigin-RevId: 715191422
  • Loading branch information
Mario Leyva authored and copybara-github committed Jan 14, 2025
1 parent 046c3be commit 8e85eeb
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions artifact/image/layerscanning/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ func FromV1Image(v1Image v1.Image, config *Config) (*Image, error) {
continue
}

// Create the chain layer directory if it doesn't exist.
dirPath := path.Join(tempPath, chainLayer.latestLayer.DiffID())

// TODO b/378491191 - Determine if an error should be thrown if the directory already exists. If
// so, we can probably use os.MkdirAll instead.
if err := os.Mkdir(dirPath, dirPermission); err != nil && !errors.Is(err, fs.ErrExist) {
return &outputImage, fmt.Errorf("failed to create chain layer directory: %w", err)
}
Expand Down

0 comments on commit 8e85eeb

Please sign in to comment.