diff --git a/changelog/unreleased/fix-ocm-upload-crush.md b/changelog/unreleased/fix-ocm-upload-crush.md new file mode 100644 index 00000000000..6cf2fd2f774 --- /dev/null +++ b/changelog/unreleased/fix-ocm-upload-crush.md @@ -0,0 +1,6 @@ +Bugfix: Fix OCM upload crush + +We fixed an issue where a federated instance crashed when uploading a file to a remote folder. +Fixed the cleanup blob and meta of the uploaded files. + +https://github.com/cs3org/reva/pull/4884 diff --git a/pkg/ocm/storage/received/upload.go b/pkg/ocm/storage/received/upload.go index 951bec8992b..154fcf9458c 100644 --- a/pkg/ocm/storage/received/upload.go +++ b/pkg/ocm/storage/received/upload.go @@ -297,6 +297,7 @@ func (u *upload) FinishUpload(ctx context.Context) error { } } + defer u.cleanup() // compare if they match the sent checksum // TODO the tus checksum extension would do this on every chunk, but I currently don't see an easy way to pass in the requested checksum. for now we do it in FinishUpload which is also called for chunked uploads if u.Info.MetaData["checksum"] != "" { @@ -316,7 +317,6 @@ func (u *upload) FinishUpload(ctx context.Context) error { err = errtypes.BadRequest("unsupported checksum algorithm: " + parts[0]) } if err != nil { - u.cleanup() return err } } @@ -336,7 +336,6 @@ func (u *upload) FinishUpload(ctx context.Context) error { Path: filepath.Join(u.Info.MetaData["dir"], u.Info.MetaData["filename"]), }) if err != nil { - u.cleanup() return err } diff --git a/pkg/rhttp/datatx/manager/tus/tus.go b/pkg/rhttp/datatx/manager/tus/tus.go index 829440ecaf9..bb724c52297 100644 --- a/pkg/rhttp/datatx/manager/tus/tus.go +++ b/pkg/rhttp/datatx/manager/tus/tus.go @@ -136,6 +136,10 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) { if err != nil { appctx.GetLogger(context.Background()).Error().Err(err).Str("session", ev.Upload.ID).Msg("failed to list upload session") } else { + if len(ups) < 1 { + appctx.GetLogger(context.Background()).Error().Str("session", ev.Upload.ID).Msg("upload session not found") + continue + } up := ups[0] executant := up.Executant() ref := up.Reference()