mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
GCS: properly check for googleapi.Error
Fixes #1936 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -434,8 +434,9 @@ func (*GCSFs) IsNotExist(err error) bool {
|
|||||||
if err == storage.ErrObjectNotExist || err == storage.ErrBucketNotExist {
|
if err == storage.ErrObjectNotExist || err == storage.ErrBucketNotExist {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if e, ok := err.(*googleapi.Error); ok {
|
var apiErr *googleapi.Error
|
||||||
if e.Code == http.StatusNotFound {
|
if errors.As(err, &apiErr) {
|
||||||
|
if apiErr.Code == http.StatusNotFound {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,8 +449,9 @@ func (*GCSFs) IsPermission(err error) bool {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if e, ok := err.(*googleapi.Error); ok {
|
var apiErr *googleapi.Error
|
||||||
if e.Code == http.StatusForbidden || e.Code == http.StatusUnauthorized {
|
if errors.As(err, &apiErr) {
|
||||||
|
if apiErr.Code == http.StatusForbidden || apiErr.Code == http.StatusUnauthorized {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user