diff --git a/changelog/unreleased/return-conflict-vs-notfound.md b/changelog/unreleased/return-conflict-vs-notfound.md new file mode 100644 index 0000000000..2315b8d83a --- /dev/null +++ b/changelog/unreleased/return-conflict-vs-notfound.md @@ -0,0 +1,7 @@ +Bugfix: return 404 when no permission to space + +WebDAV expects a 409 response when trying to upload into a non existing folder. We fixed the implementation to return 404 when a user has no access to a space and still return a 409 when a parent folder does not exist (and he has access to the space). + +https://github.com/cs3org/reva/pull/3368 +https://github.com/cs3org/reva/pull/3300 +https://github.com/owncloud/ocis/issues/3561 diff --git a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 4df0f21ed1..47886f5358 100644 --- a/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -206,10 +206,15 @@ func (s *service) InitiateFileUpload(ctx context.Context, req *provider.Initiate Interface("ref", req.Ref). Interface("received_share", receivedShare). Msg("sharesstorageprovider: Got InitiateFileUpload request") - if err != nil { + switch { + case err != nil: return nil, err - } - if rpcStatus.Code != rpc.Code_CODE_OK { + case rpcStatus.Code == rpc.Code_CODE_NOT_FOUND: + // the user has access (it showed up in the clist of shares), but we cannot write here + return &provider.InitiateFileUploadResponse{ + Status: status.NewFailedPrecondition(ctx, nil, rpcStatus.GetMessage()), + }, nil + case rpcStatus.Code != rpc.Code_CODE_OK: return &provider.InitiateFileUploadResponse{ Status: rpcStatus, }, nil diff --git a/internal/http/services/owncloud/ocdav/put.go b/internal/http/services/owncloud/ocdav/put.go index 2ef1415149..b813f03389 100644 --- a/internal/http/services/owncloud/ocdav/put.go +++ b/internal/http/services/owncloud/ocdav/put.go @@ -245,7 +245,7 @@ func (s *svc) handlePut(ctx context.Context, w http.ResponseWriter, r *http.Requ case rpc.Code_CODE_FAILED_PRECONDITION: w.WriteHeader(http.StatusConflict) case rpc.Code_CODE_NOT_FOUND: - w.WriteHeader(http.StatusConflict) + w.WriteHeader(http.StatusNotFound) default: errors.HandleErrorStatus(&log, w, uRes.Status) } diff --git a/pkg/storage/utils/decomposedfs/upload.go b/pkg/storage/utils/decomposedfs/upload.go index e333747081..3cc5485d3f 100644 --- a/pkg/storage/utils/decomposedfs/upload.go +++ b/pkg/storage/utils/decomposedfs/upload.go @@ -145,7 +145,12 @@ func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Refere log := appctx.GetLogger(ctx) n, err := fs.lu.NodeFromResource(ctx, ref) - if err != nil { + switch err.(type) { + case nil: + // ok + case errtypes.IsNotFound: + return nil, errtypes.PreconditionFailed(err.Error()) + default: return nil, err }