Skip to content

Commit

Permalink
let the gateway filter invalid references (#1274)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic authored Oct 23, 2020
1 parent 5017ab4 commit cdb3d66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/gateway-filter-invalid-references.md
Original file line number Diff line number Diff line change
@@ -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
18 changes: 11 additions & 7 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit cdb3d66

Please sign in to comment.