mirror of
https://github.com/drakkan/sftpgo.git
synced 2026-03-14 22:35:52 +01:00
GCS: properly check for googleapi.Error
Fixes #1936 Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
e590deebe0
commit
a71e53c8c8
1 changed files with 6 additions and 4 deletions
|
|
@ -434,8 +434,9 @@ func (*GCSFs) IsNotExist(err error) bool {
|
|||
if err == storage.ErrObjectNotExist || err == storage.ErrBucketNotExist {
|
||||
return true
|
||||
}
|
||||
if e, ok := err.(*googleapi.Error); ok {
|
||||
if e.Code == http.StatusNotFound {
|
||||
var apiErr *googleapi.Error
|
||||
if errors.As(err, &apiErr) {
|
||||
if apiErr.Code == http.StatusNotFound {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
@ -448,8 +449,9 @@ func (*GCSFs) IsPermission(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
if e, ok := err.(*googleapi.Error); ok {
|
||||
if e.Code == http.StatusForbidden || e.Code == http.StatusUnauthorized {
|
||||
var apiErr *googleapi.Error
|
||||
if errors.As(err, &apiErr) {
|
||||
if apiErr.Code == http.StatusForbidden || apiErr.Code == http.StatusUnauthorized {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue