Skip to content

Commit

Permalink
Merge pull request #4446 from 2403905/issue-8127
Browse files Browse the repository at this point in the history
disallow to delete a file during the processing
  • Loading branch information
butonic authored Jan 9, 2024
2 parents 2426353 + 2fd2cf4 commit 8e811d6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-deleting-during-postprocessing.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 15 additions & 1 deletion internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 8e811d6

Please sign in to comment.