diff --git a/changelog/unreleased/fix-deleting-during-postprocessing.md b/changelog/unreleased/fix-deleting-during-postprocessing.md new file mode 100644 index 0000000000..a4efff8bce --- /dev/null +++ b/changelog/unreleased/fix-deleting-during-postprocessing.md @@ -0,0 +1,5 @@ +Bugfix: Disallow to delete a file during the processing + +We want to disallow deleting a file during the processing to prevent collecting the orphan uploads. + +https://github.com/cs3org/reva/pull/4446 diff --git a/internal/grpc/services/storageprovider/storageprovider.go b/internal/grpc/services/storageprovider/storageprovider.go index 532854a290..c125698c0b 100644 --- a/internal/grpc/services/storageprovider/storageprovider.go +++ b/internal/grpc/services/storageprovider/storageprovider.go @@ -702,13 +702,27 @@ func (s *service) Delete(ctx context.Context, req *provider.DeleteRequest) (*pro } } - md, err := s.storage.GetMD(ctx, req.Ref, []string{}, []string{"id"}) + md, err := s.storage.GetMD(ctx, req.Ref, []string{}, []string{"id", "status"}) if err != nil { return &provider.DeleteResponse{ Status: status.NewStatusFromErrType(ctx, "can't stat resource to delete", err), }, nil } + if utils.ReadPlainFromOpaque(md.GetOpaque(), "status") == "processing" { + return &provider.DeleteResponse{ + Status: &rpc.Status{ + Code: rpc.Code_CODE_UNAVAILABLE, + Message: "file is processing", + }, + Opaque: &typesv1beta1.Opaque{ + Map: map[string]*typesv1beta1.OpaqueEntry{ + "status": {Decoder: "plain", Value: []byte("processing")}, + }, + }, + }, nil + } + err = s.storage.Delete(ctx, req.Ref) return &provider.DeleteResponse{