mirror of
https://github.com/containers/podman.git
synced 2025-07-02 00:30:00 +08:00
pkg/trust: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/containers/common/pkg/config"
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/containers/storage/pkg/homedir"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -61,7 +62,7 @@ func DefaultPolicyPath(sys *types.SystemContext) string {
|
||||
}
|
||||
|
||||
userPolicyFilePath := filepath.Join(homedir.Get(), filepath.FromSlash(".config/containers/policy.json"))
|
||||
_, err := os.Stat(userPolicyFilePath)
|
||||
err := fileutils.Exists(userPolicyFilePath)
|
||||
if err == nil {
|
||||
return userPolicyFilePath
|
||||
}
|
||||
@ -218,7 +219,7 @@ func AddPolicyEntries(policyPath string, input AddPolicyEntriesInput) error {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = os.Stat(policyPath)
|
||||
err = fileutils.Exists(policyPath)
|
||||
if !os.IsNotExist(err) {
|
||||
policyContent, err := os.ReadFile(policyPath)
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/storage/pkg/fileutils"
|
||||
"github.com/docker/docker/pkg/homedir"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
@ -39,7 +40,7 @@ func RegistriesDirPath(sys *types.SystemContext) string {
|
||||
return sys.RegistriesDirPath
|
||||
}
|
||||
userRegistriesDirPath := filepath.Join(homedir.Get(), userRegistriesDir)
|
||||
if _, err := os.Stat(userRegistriesDirPath); err == nil {
|
||||
if err := fileutils.Exists(userRegistriesDirPath); err == nil {
|
||||
return userRegistriesDirPath
|
||||
}
|
||||
if sys != nil && sys.RootForImplicitAbsolutePaths != "" {
|
||||
|
Reference in New Issue
Block a user