From 83d58cdcee689778188a55d358b049dad94a7807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Wed, 8 Dec 2021 17:15:46 +0100 Subject: [PATCH] Fix listing directories using the static registry --- .../grpc/services/gateway/storageprovider.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/grpc/services/gateway/storageprovider.go b/internal/grpc/services/gateway/storageprovider.go index 82fec07927f..d33ff672502 100644 --- a/internal/grpc/services/gateway/storageprovider.go +++ b/internal/grpc/services/gateway/storageprovider.go @@ -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 { @@ -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{