fixed the response code when DELETE and MOVE requests to the file that is still in post-processing
This commit is contained in:
+6
-2
@@ -183,6 +183,7 @@ type GatewayAPIClient interface {
|
||||
// then the entire directory is deleted recursively.
|
||||
// If a resource specifies a reference or symlink type, only the reference is removed (not the target).
|
||||
// MUST return CODE_NOT_FOUND if the reference does not exist.
|
||||
// MUST return CODE_TOO_EARLY if some are not finished job over resource is still in process.
|
||||
Delete(ctx context.Context, in *v1beta11.DeleteRequest, opts ...grpc.CallOption) (*v1beta11.DeleteResponse, error)
|
||||
// Returns the path reference for
|
||||
// the provided resource id reference.
|
||||
@@ -220,7 +221,8 @@ type GatewayAPIClient interface {
|
||||
ListRecycle(ctx context.Context, in *v1beta11.ListRecycleRequest, opts ...grpc.CallOption) (*v1beta11.ListRecycleResponse, error)
|
||||
// Moves a resource from one reference to another.
|
||||
// MUST return CODE_NOT_FOUND if any of the references do not exist.
|
||||
// MUST return CODE_FAILED_PRECONDITION if the source reference
|
||||
// MUST return CODE_FAILED_PRECONDITION if the source reference.
|
||||
// MUST return CODE_TOO_EARLY if some are not finished job over resource is still in process.
|
||||
// cannot be moved to the destination reference.
|
||||
Move(ctx context.Context, in *v1beta11.MoveRequest, opts ...grpc.CallOption) (*v1beta11.MoveResponse, error)
|
||||
// Permanently removes a recycle item from the recycle.
|
||||
@@ -1417,6 +1419,7 @@ type GatewayAPIServer interface {
|
||||
// then the entire directory is deleted recursively.
|
||||
// If a resource specifies a reference or symlink type, only the reference is removed (not the target).
|
||||
// MUST return CODE_NOT_FOUND if the reference does not exist.
|
||||
// MUST return CODE_TOO_EARLY if some are not finished job over resource is still in process.
|
||||
Delete(context.Context, *v1beta11.DeleteRequest) (*v1beta11.DeleteResponse, error)
|
||||
// Returns the path reference for
|
||||
// the provided resource id reference.
|
||||
@@ -1454,7 +1457,8 @@ type GatewayAPIServer interface {
|
||||
ListRecycle(context.Context, *v1beta11.ListRecycleRequest) (*v1beta11.ListRecycleResponse, error)
|
||||
// Moves a resource from one reference to another.
|
||||
// MUST return CODE_NOT_FOUND if any of the references do not exist.
|
||||
// MUST return CODE_FAILED_PRECONDITION if the source reference
|
||||
// MUST return CODE_FAILED_PRECONDITION if the source reference.
|
||||
// MUST return CODE_TOO_EARLY if some are not finished job over resource is still in process.
|
||||
// cannot be moved to the destination reference.
|
||||
Move(context.Context, *v1beta11.MoveRequest) (*v1beta11.MoveResponse, error)
|
||||
// Permanently removes a recycle item from the recycle.
|
||||
|
||||
+23
-14
@@ -209,6 +209,12 @@ const (
|
||||
//
|
||||
// HTTP Mapping: 423 Locked
|
||||
Code_CODE_LOCKED Code = 20
|
||||
// The server returns the response status code to indicate that it has received
|
||||
// the request but is not going to process it because an asynchronous job
|
||||
// that has been started is still being processed and the result can not yet be provided.
|
||||
//
|
||||
// HTTP Mapping: 425 Too Early
|
||||
Code_CODE_TOO_EARLY Code = 21
|
||||
)
|
||||
|
||||
// Enum value maps for Code.
|
||||
@@ -235,6 +241,7 @@ var (
|
||||
18: "CODE_REDIRECTION",
|
||||
19: "CODE_INSUFFICIENT_STORAGE",
|
||||
20: "CODE_LOCKED",
|
||||
21: "CODE_TOO_EARLY",
|
||||
}
|
||||
Code_value = map[string]int32{
|
||||
"CODE_INVALID": 0,
|
||||
@@ -258,6 +265,7 @@ var (
|
||||
"CODE_REDIRECTION": 18,
|
||||
"CODE_INSUFFICIENT_STORAGE": 19,
|
||||
"CODE_LOCKED": 20,
|
||||
"CODE_TOO_EARLY": 21,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -293,7 +301,7 @@ var File_cs3_rpc_v1beta1_code_proto protoreflect.FileDescriptor
|
||||
var file_cs3_rpc_v1beta1_code_proto_rawDesc = []byte{
|
||||
0x0a, 0x1a, 0x63, 0x73, 0x33, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61,
|
||||
0x31, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x63, 0x73,
|
||||
0x33, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2a, 0xe4, 0x03,
|
||||
0x33, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2a, 0xf8, 0x03,
|
||||
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x49,
|
||||
0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x44, 0x45,
|
||||
0x5f, 0x4f, 0x4b, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x43, 0x41,
|
||||
@@ -324,19 +332,20 @@ var file_cs3_rpc_v1beta1_code_proto_rawDesc = []byte{
|
||||
0x4f, 0x4e, 0x10, 0x12, 0x12, 0x1d, 0x0a, 0x19, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x49, 0x4e, 0x53,
|
||||
0x55, 0x46, 0x46, 0x49, 0x43, 0x49, 0x45, 0x4e, 0x54, 0x5f, 0x53, 0x54, 0x4f, 0x52, 0x41, 0x47,
|
||||
0x45, 0x10, 0x13, 0x12, 0x0f, 0x0a, 0x0b, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x4c, 0x4f, 0x43, 0x4b,
|
||||
0x45, 0x44, 0x10, 0x14, 0x42, 0xb7, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x73, 0x33,
|
||||
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x43, 0x6f,
|
||||
0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75,
|
||||
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x73, 0x33, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x6f, 0x2d,
|
||||
0x63, 0x73, 0x33, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x63, 0x73, 0x33, 0x2f, 0x72, 0x70, 0x63, 0x2f,
|
||||
0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x72, 0x70, 0x63, 0x76, 0x31, 0x62, 0x65, 0x74,
|
||||
0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x52, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x73, 0x33, 0x2e, 0x52,
|
||||
0x70, 0x63, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x73, 0x33,
|
||||
0x5c, 0x52, 0x70, 0x63, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1b, 0x43,
|
||||
0x73, 0x33, 0x5c, 0x52, 0x70, 0x63, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47,
|
||||
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, 0x73, 0x33,
|
||||
0x3a, 0x3a, 0x52, 0x70, 0x63, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x45, 0x44, 0x10, 0x14, 0x12, 0x12, 0x0a, 0x0e, 0x43, 0x4f, 0x44, 0x45, 0x5f, 0x54, 0x4f, 0x4f,
|
||||
0x5f, 0x45, 0x41, 0x52, 0x4c, 0x59, 0x10, 0x15, 0x42, 0xb7, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x63, 0x73, 0x33, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
|
||||
0x42, 0x09, 0x43, 0x6f, 0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x73, 0x33, 0x6f, 0x72, 0x67,
|
||||
0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x73, 0x33, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x63, 0x73, 0x33, 0x2f,
|
||||
0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x72, 0x70, 0x63, 0x76,
|
||||
0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x52, 0x58, 0xaa, 0x02, 0x0f, 0x43,
|
||||
0x73, 0x33, 0x2e, 0x52, 0x70, 0x63, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02,
|
||||
0x0f, 0x43, 0x73, 0x33, 0x5c, 0x52, 0x70, 0x63, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31,
|
||||
0xe2, 0x02, 0x1b, 0x43, 0x73, 0x33, 0x5c, 0x52, 0x70, 0x63, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74,
|
||||
0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
|
||||
0x11, 0x43, 0x73, 0x33, 0x3a, 0x3a, 0x52, 0x70, 0x63, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74,
|
||||
0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -731,7 +731,7 @@ func (s *Service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro
|
||||
if utils.ReadPlainFromOpaque(md.GetOpaque(), "status") == "processing" {
|
||||
return &provider.DeleteResponse{
|
||||
Status: &rpc.Status{
|
||||
Code: rpc.Code_CODE_UNAVAILABLE,
|
||||
Code: rpc.Code_CODE_TOO_EARLY,
|
||||
Message: "file is processing",
|
||||
},
|
||||
Opaque: &typesv1beta1.Opaque{
|
||||
|
||||
+20
@@ -195,6 +195,14 @@ func (e InsufficientStorage) Body() []byte {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/507
|
||||
const StatusInsufficientStorage = 507
|
||||
|
||||
// TooEarly is the error to use when some are not finished job over resource is still in process.
|
||||
type TooEarly string
|
||||
|
||||
func (e TooEarly) Error() string { return "error: too early: " + string(e) }
|
||||
|
||||
// IsTooEarly implements the IsTooEarly interface.
|
||||
func (e TooEarly) IsTooEarly() {}
|
||||
|
||||
// IsNotFound is the interface to implement
|
||||
// to specify that a resource is not found.
|
||||
type IsNotFound interface {
|
||||
@@ -279,6 +287,12 @@ type IsInsufficientStorage interface {
|
||||
IsInsufficientStorage()
|
||||
}
|
||||
|
||||
// IsTooEarly is the interface to implement
|
||||
// to specify that there is some not finished job over resource is still in process.
|
||||
type IsTooEarly interface {
|
||||
IsTooEarly()
|
||||
}
|
||||
|
||||
// NewErrtypeFromStatus maps a rpc status to an errtype
|
||||
func NewErrtypeFromStatus(status *rpc.Status) error {
|
||||
switch status.Code {
|
||||
@@ -313,6 +327,8 @@ func NewErrtypeFromStatus(status *rpc.Status) error {
|
||||
return InsufficientStorage(status.Message)
|
||||
case rpc.Code_CODE_INVALID_ARGUMENT, rpc.Code_CODE_OUT_OF_RANGE:
|
||||
return BadRequest(status.Message)
|
||||
case rpc.Code_CODE_TOO_EARLY:
|
||||
return TooEarly(status.Message)
|
||||
default:
|
||||
return InternalError(status.Message)
|
||||
}
|
||||
@@ -345,6 +361,8 @@ func NewErrtypeFromHTTPStatusCode(code int, message string) error {
|
||||
return BadRequest(message)
|
||||
case http.StatusPartialContent:
|
||||
return PartialContent(message)
|
||||
case http.StatusTooEarly:
|
||||
return TooEarly(message)
|
||||
case StatusChecksumMismatch:
|
||||
return ChecksumMismatch(message)
|
||||
default:
|
||||
@@ -379,6 +397,8 @@ func NewHTTPStatusCodeFromErrtype(err error) int {
|
||||
return http.StatusBadRequest
|
||||
case PartialContent:
|
||||
return http.StatusPartialContent
|
||||
case TooEarly:
|
||||
return http.StatusTooEarly
|
||||
case ChecksumMismatch:
|
||||
return StatusChecksumMismatch
|
||||
default:
|
||||
|
||||
+1
@@ -253,6 +253,7 @@ var httpStatusCode = map[rpc.Code]int{
|
||||
rpc.Code_CODE_UNIMPLEMENTED: http.StatusNotImplemented,
|
||||
rpc.Code_CODE_UNKNOWN: http.StatusInternalServerError,
|
||||
rpc.Code_CODE_LOCKED: http.StatusLocked,
|
||||
rpc.Code_CODE_TOO_EARLY: http.StatusTooEarly,
|
||||
}
|
||||
|
||||
// HTTPStatusFromCode returns an HTTP status code for the rpc code. It returns
|
||||
|
||||
Reference in New Issue
Block a user