Skip to content

Commit

Permalink
Fix listing directories using the static registry
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Dec 13, 2021
1 parent bab7bb7 commit 83d58cd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,15 @@ func (s *svc) ListContainer(ctx context.Context, req *provider.ListContainerRequ
}

if utils.IsAbsoluteReference(req.Ref) {
var prefix string
if utils.IsAbsolutePathReference(req.Ref) {
prefix = mountPath
} else {
prefix = path.Join(mountPath, providerRef.Path)
}
for j := range rsp.Infos {
rsp.Infos[j].Path = path.Join(mountPath, providerRef.Path, rsp.Infos[j].Path)

rsp.Infos[j].Path = path.Join(prefix, rsp.Infos[j].Path)
}
}
for i := range rsp.Infos {
Expand Down Expand Up @@ -1603,18 +1610,18 @@ func (s *svc) findProviders(ctx context.Context, ref *provider.Reference) ([]*re
return res.Providers, nil
}

// unwrap takes a reference and makes it relative to the given mountPoint, optionally
// unwrap takes a reference and builds a reference for the provider. can be absolute or relative to a root node
func unwrap(ref *provider.Reference, mountPoint string, root *provider.ResourceId) *provider.Reference {
if utils.IsAbsolutePathReference(ref) {
relativeRef := &provider.Reference{
providerRef := &provider.Reference{
Path: strings.TrimPrefix(ref.Path, mountPoint),
}
// if we have a root use it and make the path relative
if root != nil {
relativeRef.ResourceId = root
relativeRef.Path = utils.MakeRelativePath(relativeRef.Path)
providerRef.ResourceId = root
providerRef.Path = utils.MakeRelativePath(providerRef.Path)
}
return relativeRef
return providerRef
}
// build a copy to avoid side effects
return &provider.Reference{
Expand Down

0 comments on commit 83d58cd

Please sign in to comment.