Skip to content

Commit

Permalink
pkg/util: use fileutils.(Le|E)xists
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Apr 19, 2024
1 parent 0e8d1ad commit 94c6991
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/containers/podman/v5/pkg/rootless"
"github.com/containers/podman/v5/pkg/signal"
"github.com/containers/storage/pkg/directory"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/unshare"
stypes "github.com/containers/storage/types"
Expand Down Expand Up @@ -97,14 +98,14 @@ func ParseDockerignore(containerfiles []string, root string) ([]string, string,
if dockerIgnoreErr != nil {
for _, containerfile := range containerfiles {
containerfile = strings.TrimPrefix(containerfile, root)
if _, err := os.Stat(filepath.Join(root, containerfile+".containerignore")); err == nil {
if err := fileutils.Exists(filepath.Join(root, containerfile+".containerignore")); err == nil {
path, symlinkErr = securejoin.SecureJoin(root, containerfile+".containerignore")
if symlinkErr == nil {
ignoreFile = path
ignore, dockerIgnoreErr = os.ReadFile(path)
}
}
if _, err := os.Stat(filepath.Join(root, containerfile+".dockerignore")); err == nil {
if err := fileutils.Exists(filepath.Join(root, containerfile+".dockerignore")); err == nil {
path, symlinkErr = securejoin.SecureJoin(root, containerfile+".dockerignore")
if symlinkErr == nil {
ignoreFile = path
Expand Down Expand Up @@ -1140,7 +1141,7 @@ func ParseInputTime(inputTime string, since bool) (time.Time, error) {
func OpenExclusiveFile(path string) (*os.File, error) {
baseDir := filepath.Dir(path)
if baseDir != "" {
if _, err := os.Stat(baseDir); err != nil {
if err := fileutils.Exists(baseDir); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit 94c6991

Please sign in to comment.