Skip to content

Commit

Permalink
Showing 3 changed files with 35 additions and 14 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-public-file-shares.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix public file shares

Fixed stat requests and propfind responses for publicly shared files.

https://github.com/cs3org/reva/pull/1666

Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ func (s *service) translatePublicRefToCS3Ref(ctx context.Context, ref *provider.
return nil, "", nil, nil, err
}

originalPath, ls, st, err := s.resolveToken(ctx, tkn)
originalPath, ls, _, st, err := s.resolveToken(ctx, tkn)
switch {
case err != nil:
return nil, "", nil, nil, err
@@ -452,7 +452,7 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide
return nil, err
}

originalPath, ls, st, err := s.resolveToken(ctx, tkn)
originalPath, ls, ri, st, err := s.resolveToken(ctx, tkn)
switch {
case err != nil:
return nil, err
@@ -466,12 +466,16 @@ func (s *service) Stat(ctx context.Context, req *provider.StatRequest) (*provide
}, nil
}

p := originalPath
if ri.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
p = path.Join("/", p, relativePath)
}
var statResponse *provider.StatResponse
// the call has to be made to the gateway instead of the storage.
statResponse, err = s.gateway.Stat(ctx, &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Path{
Path: path.Join("/", originalPath, relativePath),
Path: p,
},
},
})
@@ -518,7 +522,7 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer
return nil, err
}

pathFromToken, ls, st, err := s.resolveToken(ctx, tkn)
pathFromToken, ls, _, st, err := s.resolveToken(ctx, tkn)
switch {
case err != nil:
return nil, err
@@ -668,10 +672,10 @@ func (s *service) trimMountPrefix(fn string) (string, error) {
}

// resolveToken returns the path and share for the publicly shared resource.
func (s *service) resolveToken(ctx context.Context, token string) (string, *link.PublicShare, *rpc.Status, error) {
func (s *service) resolveToken(ctx context.Context, token string) (string, *link.PublicShare, *provider.ResourceInfo, *rpc.Status, error) {
driver, err := pool.GetGatewayServiceClient(s.conf.GatewayAddr)
if err != nil {
return "", nil, nil, err
return "", nil, nil, nil, err
}

publicShareResponse, err := driver.GetPublicShare(
@@ -687,19 +691,33 @@ func (s *service) resolveToken(ctx context.Context, token string) (string, *link
)
switch {
case err != nil:
return "", nil, nil, err
return "", nil, nil, nil, err
case publicShareResponse.Status.Code != rpc.Code_CODE_OK:
return "", nil, publicShareResponse.Status, nil
return "", nil, nil, publicShareResponse.Status, nil
}

pathRes, err := s.gateway.GetPath(ctx, &provider.GetPathRequest{
ResourceId: publicShareResponse.GetShare().GetResourceId(),
})
switch {
case err != nil:
return "", nil, nil, err
return "", nil, nil, nil, err
case pathRes.Status.Code != rpc.Code_CODE_OK:
return "", nil, pathRes.Status, nil
return "", nil, nil, pathRes.Status, nil
}

sRes, err := s.gateway.Stat(ctx, &provider.StatRequest{
Ref: &provider.Reference{
Spec: &provider.Reference_Id{
Id: publicShareResponse.GetShare().GetResourceId(),
},
},
})
switch {
case err != nil:
return "", nil, nil, nil, err
case sRes.Status.Code != rpc.Code_CODE_OK:
return "", nil, nil, sRes.Status, nil
}
return pathRes.Path, publicShareResponse.GetShare(), nil, nil
return pathRes.Path, publicShareResponse.GetShare(), sRes.Info, nil, nil
}
3 changes: 0 additions & 3 deletions internal/http/services/owncloud/ocdav/publicfile.go
Original file line number Diff line number Diff line change
@@ -231,9 +231,6 @@ func (s *svc) getPublicFileInfos(onContainer, onlyRoot bool, i *provider.Resourc
}
}

// link share only appears on root collection
delete(i.Opaque.Map, "link-share")

// add the file info
infos = append(infos, i)

0 comments on commit 69bd21f

Please sign in to comment.