Skip to content

Commit

Permalink
Do not wrap errors from filepath and stat as they are already wrapped.
Browse files Browse the repository at this point in the history
Since errors from filepath and lstat are already wrapped, they
do not need to be wrapped again. Wrapping them again will
cause os.IsErrNotExist(err) to return false while some providers
may want it to be true.

Signed-off-by: Manu Gupta <manugupt1@gmail.com>
  • Loading branch information
manugupt1 committed Apr 7, 2022
1 parent 0335593 commit 233b438
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mountinfo/mounted_unix.go
Expand Up @@ -33,13 +33,13 @@ func mountedByStat(path string) (bool, error) {

func normalizePath(path string) (realPath string, err error) {
if realPath, err = filepath.Abs(path); err != nil {
return "", fmt.Errorf("unable to get absolute path for %q: %w", path, err)
return "", err
}
if realPath, err = filepath.EvalSymlinks(realPath); err != nil {
return "", fmt.Errorf("failed to canonicalise path for %q: %w", path, err)
return "", err
}
if _, err := os.Stat(realPath); err != nil {
return "", fmt.Errorf("failed to stat target of %q: %w", path, err)
return "", err
}
return realPath, nil
}
Expand Down

0 comments on commit 233b438

Please sign in to comment.