Stop DBus errors from causing panics by checking error type (Arsen6331/itd#29)

This commit is contained in:
Arsen Musayelyan 2022-10-17 12:19:23 -07:00
parent 01970b2bb7
commit bb017b471e
1 changed files with 21 additions and 3 deletions

View File

@ -23,7 +23,13 @@ func (blefs *FS) RemoveAll(path string) error {
return blefs.removeAllChildren(path)
} else {
err = blefs.Remove(path)
if err != nil && err.(FSError).Code != -2 {
var code int8
if err, ok := err.(FSError); ok {
code = err.Code
}
if err != nil && code != -2 {
return err
}
}
@ -50,7 +56,13 @@ func (blefs *FS) removeAllChildren(path string) error {
} else {
err = blefs.Remove(entryPath)
}
if err != nil && err.(FSError).Code != -2 {
var code int8
if err, ok := err.(FSError); ok {
code = err.Code
}
if err != nil && code != -2 {
return err
}
}
@ -68,7 +80,13 @@ func (blefs *FS) MkdirAll(path string) error {
curPath := strings.Join(splitPath[0:i+1], "/")
err := blefs.Mkdir(curPath)
if err != nil && err.(FSError).Code != -17 {
var code int8
if err, ok := err.(FSError); ok {
code = err.Code
}
if err != nil && code != -17 {
return err
}
}