mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-18 13:45:09 +00:00
fix namespaceing of files
This commit is contained in:
@@ -60,14 +60,10 @@ func (e *File) Read(ctx context.Context, req *file.ReadRequest, rsp *file.ReadRe
|
|||||||
if file.Project != project {
|
if file.Project != project {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// check file path matches tenants
|
|
||||||
if !strings.HasPrefix(file.Path, tenantId+"/"+req.Project) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// strip the tenant id
|
// strip the tenant id
|
||||||
file.Project = strings.TrimPrefix(file.Project, tenantId+"/")
|
file.Project = strings.TrimPrefix(file.Project, tenantId+"/")
|
||||||
file.Path = strings.TrimPrefix(file.Path, tenantId+"/"+req.Project+"/")
|
file.Path = strings.TrimPrefix(file.Path, req.Project+"/")
|
||||||
|
|
||||||
// check the path matches the request
|
// check the path matches the request
|
||||||
if req.Path == file.Path {
|
if req.Path == file.Path {
|
||||||
@@ -144,9 +140,13 @@ func (e *File) List(ctx context.Context, req *file.ListRequest, rsp *file.ListRe
|
|||||||
// query for the KV store interface, it's not supported by the model
|
// query for the KV store interface, it's not supported by the model
|
||||||
// so we do client side filtering here
|
// so we do client side filtering here
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
|
if file.Project != project {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// strip the prefixes
|
// strip the prefixes
|
||||||
file.Project = strings.TrimPrefix(file.Project, tenantId+"/")
|
file.Project = strings.TrimPrefix(file.Project, tenantId+"/")
|
||||||
file.Path = strings.TrimPrefix(file.Path, tenantId+"/"+req.Project+"/")
|
file.Path = strings.TrimPrefix(file.Path, req.Project+"/")
|
||||||
|
|
||||||
// strip the file contents
|
// strip the file contents
|
||||||
// no file listing ever contains it
|
// no file listing ever contains it
|
||||||
|
|||||||
Reference in New Issue
Block a user