From cdb3d6688da59b63df6d6ade4ed7331e161c9cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 23 Oct 2020 16:42:16 +0200 Subject: [PATCH] let the gateway filter invalid references (#1274) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .../gateway-filter-invalid-references.md | 5 +++++ .../grpc/services/gateway/storageprovider.go | 18 +++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/gateway-filter-invalid-references.md diff --git a/changelog/unreleased/gateway-filter-invalid-references.md b/changelog/unreleased/gateway-filter-invalid-references.md new file mode 100644 index 0000000000..cd4ce50451 --- /dev/null +++ b/changelog/unreleased/gateway-filter-invalid-references.md @@ -0,0 +1,5 @@ +Bugfix: let the gateway filter invalid references + +We now filter deleted and unshared entries from the response when listing the shares folder of a user. + +https://github.com/cs3org/reva/pull/1274 \ No newline at end of file diff --git a/internal/grpc/services/gateway/storageprovider.go b/internal/grpc/services/gateway/storageprovider.go index c3ce926199..aa44ba6f40 100644 --- a/internal/grpc/services/gateway/storageprovider.go +++ b/internal/grpc/services/gateway/storageprovider.go @@ -1623,29 +1623,33 @@ func (s *svc) listSharesFolder(ctx context.Context) (*provider.ListContainerResp Status: status.NewInternal(ctx, err, "gateway: error listing shared folder"), }, nil } - - for i, ref := range lcr.Infos { - info, protocol, err := s.checkRef(ctx, ref) + checkedInfos := make([]*provider.ResourceInfo, 0) + for i := range lcr.Infos { + info, protocol, err := s.checkRef(ctx, lcr.Infos[i]) if _, ok := err.(errtypes.IsNotFound); ok { // this might arise when the shared resource has been moved to the recycle bin continue + } else if _, ok := err.(errtypes.PermissionDenied); ok { + // this might arise when the resource was unshared, but the share reference was not removed + continue } else if err != nil { return &provider.ListContainerResponse{ - Status: status.NewInternal(ctx, err, "gateway: error resolving reference:"+ref.Path), + Status: status.NewInternal(ctx, err, "gateway: error resolving reference:"+lcr.Infos[i].Path), }, nil } if protocol == "webdav" { - info, err = s.webdavRefStat(ctx, ref.Target) + info, err = s.webdavRefStat(ctx, lcr.Infos[i].Target) if err != nil { // Might be the case that the webdav token has expired continue } } - info.Path = ref.GetPath() - lcr.Infos[i] = info + info.Path = lcr.Infos[i].GetPath() + checkedInfos = append(checkedInfos, info) } + lcr.Infos = checkedInfos return lcr, nil }