mirror of https://github.com/spf13/afero.git
Merge pull request #67 from tatsushid/fix/copyonwritefs-patherr-handling
Fix CopyOnWriteFs Stat to handle *os.PathError
This commit is contained in:
commit
4c1d2aade6
|
@ -75,14 +75,17 @@ func (u *CopyOnWriteFs) Chmod(name string, mode os.FileMode) error {
|
||||||
|
|
||||||
func (u *CopyOnWriteFs) Stat(name string) (os.FileInfo, error) {
|
func (u *CopyOnWriteFs) Stat(name string) (os.FileInfo, error) {
|
||||||
fi, err := u.layer.Stat(name)
|
fi, err := u.layer.Stat(name)
|
||||||
switch err {
|
if err != nil {
|
||||||
case nil:
|
origErr := err
|
||||||
return fi, nil
|
if e, ok := err.(*os.PathError); ok {
|
||||||
case syscall.ENOENT:
|
err = e.Err
|
||||||
return u.base.Stat(name)
|
}
|
||||||
default:
|
if err == syscall.ENOENT {
|
||||||
return nil, err
|
return u.base.Stat(name)
|
||||||
|
}
|
||||||
|
return nil, origErr
|
||||||
}
|
}
|
||||||
|
return fi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renaming files present only in the base layer is not permitted
|
// Renaming files present only in the base layer is not permitted
|
||||||
|
|
Loading…
Reference in New Issue