Stop DBus errors from causing panics by checking error type (Arsen6331/itd#29)
This commit is contained in:
parent
5f6b0205da
commit
e124e1ccbd
24
blefs/all.go
24
blefs/all.go
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user