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

Removed stat to all storage providers on a Depth:0 PROPFIND to "/" #4497

Merged
merged 4 commits into from
Feb 6, 2024
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
6 changes: 6 additions & 0 deletions changelog/unreleased/zerodepth-propfind-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: removed stat to all storage providers on Depth:0 PROPFIND to "/"

This PR removes an unnecessary and potentially problematic call, which would
fail if any of the configured storage providers has an issue.

https://github.com/cs3org/reva/pull/4497
36 changes: 2 additions & 34 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1419,12 +1419,8 @@ func (s *svc) stat(ctx context.Context, req *provider.StatRequest) (*provider.St
return rsp, nil
}

return s.statAcrossProviders(ctx, req, providers)
}

func (s *svc) statAcrossProviders(ctx context.Context, req *provider.StatRequest, providers []*registry.ProviderInfo) (*provider.StatResponse, error) {
// TODO(ishank011): aggregrate properties such as etag, checksum, etc.
log := appctx.GetLogger(ctx)
// otherwise, this is a Stat for "/", which corresponds to a 0-Depth PROPFIND from web to just get the fileid:
// we respond with an hardcoded value, no need to poke all storage providers as we did before
info := &provider.ResourceInfo{
Id: &provider.ResourceId{
StorageId: "/",
Expand All @@ -1437,34 +1433,6 @@ func (s *svc) statAcrossProviders(ctx context.Context, req *provider.StatRequest
Mtime: &types.Timestamp{},
}

for _, p := range providers {
c, err := s.getStorageProviderClient(ctx, p)
if err != nil {
log.Err(err).Msg("error connecting to storage provider=" + p.Address)
continue
}
resp, err := c.Stat(ctx, req)
if err != nil {
log.Err(err).Msgf("gateway: error calling Stat %s: %+v", req.Ref.String(), p)
continue
}
if resp.Status.Code != rpc.Code_CODE_OK {
log.Err(status.NewErrorFromCode(rpc.Code_CODE_OK, "gateway")).Send()
continue
}
if resp.Info != nil {
info.Size += resp.Info.Size
if utils.TSToUnixNano(resp.Info.Mtime) > utils.TSToUnixNano(info.Mtime) {
info.Mtime = resp.Info.Mtime
info.Etag = resp.Info.Etag
info.Checksum = resp.Info.Checksum
}
if info.Etag == "" && info.Etag != resp.Info.Etag {
info.Etag = resp.Info.Etag
}
}
}

return &provider.StatResponse{
Status: status.NewOK(ctx),
Info: info,
Expand Down
Loading