From 9db7871f4ce323c9771abaf371d8ea125d901fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 4 Oct 2024 15:44:10 +0200 Subject: [PATCH] continue listing shares on error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../continue-listing-shares-on-error.md | 5 +++ services/graph/pkg/service/v0/sharedwithme.go | 2 +- services/graph/pkg/service/v0/utils.go | 45 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 changelog/unreleased/continue-listing-shares-on-error.md diff --git a/changelog/unreleased/continue-listing-shares-on-error.md b/changelog/unreleased/continue-listing-shares-on-error.md new file mode 100644 index 00000000000..35bc1a8eeca --- /dev/null +++ b/changelog/unreleased/continue-listing-shares-on-error.md @@ -0,0 +1,5 @@ +Bugfix: Continue listing shares on error + +We now continue listing received shares when one of the shares cannot be statted or converted to a driveItem. + +https://github.com/owncloud/ocis/pull/10243 diff --git a/services/graph/pkg/service/v0/sharedwithme.go b/services/graph/pkg/service/v0/sharedwithme.go index 454665d8e28..0a51d8b0880 100644 --- a/services/graph/pkg/service/v0/sharedwithme.go +++ b/services/graph/pkg/service/v0/sharedwithme.go @@ -55,7 +55,7 @@ func (g Graph) listSharedWithMe(ctx context.Context) ([]libregraph.DriveItem, er } ocmDriveItems, err := cs3ReceivedOCMSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, listReceivedOCMSharesResponse.GetShares(), availableRoles) if err != nil { - g.logger.Error().Err(err).Msg("could not convert received shares to drive items") + g.logger.Error().Err(err).Msg("could not convert received ocm shares to drive items") return nil, err } driveItems = append(driveItems, ocmDriveItems...) diff --git a/services/graph/pkg/service/v0/utils.go b/services/graph/pkg/service/v0/utils.go index b554d52677d..02a15dea105 100644 --- a/services/graph/pkg/service/v0/utils.go +++ b/services/graph/pkg/service/v0/utils.go @@ -3,7 +3,6 @@ package svc import ( "context" "encoding/json" - "errors" "io" "net/http" "reflect" @@ -203,23 +202,21 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context, }, }) - var errCode errorcode.Error - errors.As(errorcode.FromCS3Status(shareStat.GetStatus(), err), &errCode) - - switch { - // skip ItemNotFound shares, they might have been deleted in the meantime or orphans. - case errCode.GetCode() == errorcode.ItemNotFound: + if err := errorcode.FromCS3Status(shareStat.GetStatus(), err); err != nil { + logger.Debug().Err(err). + Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()). + Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())). + Msg("could not stat received share, skipping") return nil - case err == nil: - break - default: - logger.Error().Err(errCode).Msg("could not stat") - return errCode } driveItem, err := fillDriveItemPropertiesFromReceivedShare(ctx, logger, identityCache, receivedShares, shareStat.GetInfo(), availableRoles) if err != nil { - return err + logger.Debug().Err(err). + Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()). + Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())). + Msg("could not fill drive item properties from received share, skipping") + return nil } if !driveItem.HasUIHidden() { @@ -553,23 +550,21 @@ func cs3ReceivedOCMSharesToDriveItems(ctx context.Context, }, }) - var errCode errorcode.Error - errors.As(errorcode.FromCS3Status(shareStat.GetStatus(), err), &errCode) - - switch { - // skip ItemNotFound shares, they might have been deleted in the meantime or orphans. - case errCode.GetCode() == errorcode.ItemNotFound: + if err := errorcode.FromCS3Status(shareStat.GetStatus(), err); err != nil { + logger.Debug().Err(err). + Str("shareid", receivedShares[0].GetId().GetOpaqueId()). + Str("remoteshareid", receivedShares[0].GetRemoteShareId()). + Msg("could not stat received ocm share, skipping") return nil - case err == nil: - break - default: - logger.Error().Err(errCode).Msg("could not stat") - return errCode } driveItem, err := fillDriveItemPropertiesFromReceivedOCMShare(ctx, logger, identityCache, receivedShares, shareStat.GetInfo(), availableRoles) if err != nil { - return err + logger.Debug().Err(err). + Str("shareid", receivedShares[0].GetId().GetOpaqueId()). + Str("remoteshareid", receivedShares[0].GetRemoteShareId()). + Msg("could not fill drive item properties from received ocm share, skipping") + return nil } if !driveItem.HasUIHidden() {