From 2578d597f5e028d7ed56b5ddc0e3781d2ca5ddb4 Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Fri, 13 Dec 2024 16:57:25 +0100 Subject: [PATCH] fix for blocking reva because buffered channel is not filled up on error --- changelog/unreleased/fix-block-on-sharedwithme.md | 5 +++++ .../ocs/handlers/apps/sharing/shares/shares.go | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/fix-block-on-sharedwithme.md diff --git a/changelog/unreleased/fix-block-on-sharedwithme.md b/changelog/unreleased/fix-block-on-sharedwithme.md new file mode 100644 index 0000000000..30e4ef9cca --- /dev/null +++ b/changelog/unreleased/fix-block-on-sharedwithme.md @@ -0,0 +1,5 @@ +Bugfix: blocking reva on listSharedWithMe + +`listSharesWithMe` blocked a reva thread in the case that one of the shares was not resolvable. This has now been fixed + +https://github.com/cs3org/reva/pull/5006 diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 1829f31b31..97a2eeb467 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -893,6 +893,8 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { workers := 50 input := make(chan *collaboration.ReceivedShare, len(lrsRes.GetShares())) output := make(chan *conversions.ShareData, len(lrsRes.GetShares())) + timeoutContext, cancel := context.WithTimeout(ctx, time.Duration(time.Millisecond*20000)) + defer cancel() for i := 0; i < workers; i++ { wg.Add(1) @@ -917,6 +919,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { info, status, err = h.getResourceInfoByID(ctx, client, rs.Share.ResourceId) if err != nil || status.Code != rpc.Code_CODE_OK { h.logProblems(status, err, "could not stat, skipping", log) + output <- nil return } } @@ -924,6 +927,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { data, err := conversions.CS3Share2ShareData(r.Context(), rs.Share) if err != nil { log.Debug().Interface("share", rs.Share.Id).Err(err).Msg("CS3Share2ShareData call failes, skipping") + output <- nil return } @@ -931,6 +935,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { if err := h.addFileInfo(ctx, data, info); err != nil { log.Debug().Interface("received_share", rs.Share.Id).Err(err).Msg("could not add file info, skipping") + output <- nil return } h.mapUserIds(r.Context(), client, data) @@ -977,7 +982,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { log.Debug().Msgf("share: %+v", data) output <- data } - }(ctx, client, input, output, &wg) + }(timeoutContext, client, input, output, &wg) } for _, share := range lrsRes.GetShares() { @@ -988,7 +993,9 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { close(output) for s := range output { - shares = append(shares, s) + if s != nil { + shares = append(shares, s) + } } if h.listOCMShares {