Skip to content

Commit

Permalink
Removed stat to all storage providers on a Depth:0 PROPFIND to "/" (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
glpatcern authored Feb 6, 2024
1 parent 5ca283c commit 989b01d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 34 deletions.
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

0 comments on commit 989b01d

Please sign in to comment.