mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-06 19:40:42 -05:00
graph/drives: Fix status code for PATCH/DELETE on drives don't allow them
Return a 405 Status when UpdateSpace() or DeleteSpace() are not implemented in the backend for a certain type of drive (e.g. the virtual mountpoint drives created for shares). Fixes: #7881
This commit is contained in:
committed by
Ralf Haferkamp
parent
6e1f3b9163
commit
f3ed318d9d
@@ -0,0 +1,7 @@
|
||||
Bugfix: fix PATCH/DELETE status code for drives that don't support them
|
||||
|
||||
Updating and Deleting the virtual drives for shares is currently not supported. Instead
|
||||
of returning a generic 500 status we return a 405 response now.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/8235
|
||||
https://github.com/owncloud/ocis/issues/7881
|
||||
@@ -622,6 +622,10 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
|
||||
logger.Debug().Interface("id", rid).Msg("could not update drive, invalid argument")
|
||||
errorcode.NotAllowed.Render(w, r, http.StatusBadRequest, resp.GetStatus().GetMessage())
|
||||
return
|
||||
case cs3rpc.Code_CODE_UNIMPLEMENTED:
|
||||
logger.Debug().Interface("id", rid).Msg("could not delete drive: delete not implemented for this type of drive")
|
||||
errorcode.NotAllowed.Render(w, r, http.StatusMethodNotAllowed, "drive cannot be updated")
|
||||
return
|
||||
default:
|
||||
logger.Debug().Interface("id", rid).Str("grpc", resp.GetStatus().GetMessage()).Msg("could not update drive: grpc error")
|
||||
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "grpc error")
|
||||
@@ -1193,6 +1197,10 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) {
|
||||
logger.Debug().Interface("id", rid).Msg("could not delete drive: drive not found")
|
||||
errorcode.ItemNotFound.Render(w, r, http.StatusNotFound, "drive not found")
|
||||
return
|
||||
case cs3rpc.Code_CODE_UNIMPLEMENTED:
|
||||
logger.Debug().Interface("id", rid).Msg("could not delete drive: delete not implemented for this type of drive")
|
||||
errorcode.NotAllowed.Render(w, r, http.StatusMethodNotAllowed, "drive cannot be deleted")
|
||||
return
|
||||
// don't expose internal error codes to the outside world
|
||||
default:
|
||||
logger.Debug().Str("grpc", dRes.GetStatus().GetMessage()).Interface("id", rid).Msg("could not delete drive: grpc error")
|
||||
|
||||
Reference in New Issue
Block a user