From 90c0f8c476ffcb7949f6a2ce992a9bc75789d489 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Thu, 3 Jun 2021 12:30:14 +0100 Subject: [PATCH] fix file read --- file/handler/files.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/file/handler/files.go b/file/handler/files.go index b7ad8f5..064c4e6 100644 --- a/file/handler/files.go +++ b/file/handler/files.go @@ -56,11 +56,21 @@ func (e *File) Read(ctx context.Context, req *file.ReadRequest, rsp *file.ReadRe // filter the file for _, file := range files { + // check project matches tenants + if file.Project != project { + continue + } + // check file path matches tenants + if !strings.HasPrefix(file.Path, tenantId+"/"+req.Project) { + continue + } + // strip the tenant id file.Project = strings.TrimPrefix(file.Project, tenantId+"/") file.Path = strings.TrimPrefix(file.Path, tenantId+"/"+req.Project+"/") - if req.Path != "" && strings.HasPrefix(file.Path, req.Path) { + // check the path matches the request + if req.Path == file.Path { rsp.File = file } }