Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let the gateway filter invalid references #1274

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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