Merge pull request #9689 from 2403905/issue-9432

fixed the response code when DELETE and MOVE requests to the file that is still in post-processing
This commit is contained in:
Roman Perekhod
2024-07-25 12:39:24 +02:00
committed by GitHub
10 changed files with 66 additions and 25 deletions

View File

@@ -3,3 +3,4 @@ Enhancement: Bump reva
https://github.com/owncloud/ocis/pull/9662
https://github.com/owncloud/ocis/pull/9621
https://github.com/owncloud/ocis/pull/9677
https://github.com/owncloud/ocis/pull/9689

View File

@@ -0,0 +1,6 @@
Bugfix: Fixed response code for DELETE file that is in postprocessing
We fixed the response code when DELETE and MOVE requests to the file that is still in post-processing.
https://github.com/owncloud/ocis/pull/9689
https://github.com/owncloud/ocis/issues/9432

4
go.mod
View File

@@ -14,8 +14,8 @@ require (
github.com/blevesearch/bleve/v2 v2.4.0
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.10.0
github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e
github.com/cs3org/reva/v2 v2.21.1-0.20240724074721-53e5aafbfb86
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb
github.com/cs3org/reva/v2 v2.21.1-0.20240725083514-19e4d645016b
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1

8
go.sum
View File

@@ -1023,10 +1023,10 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo
github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4=
github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e h1:Cm2l8m2riLa79eh7V2wHd1Ra7wR3TbngmeLZBJ9MxTU=
github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.21.1-0.20240724074721-53e5aafbfb86 h1:gJkzSPurbNq7x+N5IjnwtKh+moUtHVQ7IRIncc4rmQ8=
github.com/cs3org/reva/v2 v2.21.1-0.20240724074721-53e5aafbfb86/go.mod h1:+5pteFc4ymQnhYG2cOtg/jzaIZKgxrgIeH0D4fuC6gA=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.21.1-0.20240725083514-19e4d645016b h1:3pq7bPCy7NUtlIWytzB4+MP8I6V8bgIdHxsrmyKbHzU=
github.com/cs3org/reva/v2 v2.21.1-0.20240725083514-19e4d645016b/go.mod h1:vz5FHfuRaLvSO6bscoWWx+29RtyJm0wIWLZciCLN3L0=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=

View File

@@ -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.

View File

@@ -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 (

View File

@@ -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{

View File

@@ -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:

View File

@@ -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

4
vendor/modules.txt vendored
View File

@@ -343,7 +343,7 @@ github.com/crewjam/saml
github.com/crewjam/saml/logger
github.com/crewjam/saml/samlsp
github.com/crewjam/saml/xmlenc
# github.com/cs3org/go-cs3apis v0.0.0-20240425114016-d2cb31692b4e
# github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb
## explicit; go 1.21
github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1
github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1
@@ -366,7 +366,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1
github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1
github.com/cs3org/go-cs3apis/cs3/tx/v1beta1
github.com/cs3org/go-cs3apis/cs3/types/v1beta1
# github.com/cs3org/reva/v2 v2.21.1-0.20240724074721-53e5aafbfb86
# github.com/cs3org/reva/v2 v2.21.1-0.20240725083514-19e4d645016b
## explicit; go 1.21
github.com/cs3org/reva/v2/cmd/revad/internal/grace
github.com/cs3org/reva/v2/cmd/revad/runtime