From e64480f634c9112ccaf48c71bafce08e2f669191 Mon Sep 17 00:00:00 2001 From: kingston125 Date: Wed, 27 May 2026 03:07:40 -0400 Subject: [PATCH] backend/filelu: fix recursive listing path handling and file filtering --- backend/filelu/filelu.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/backend/filelu/filelu.go b/backend/filelu/filelu.go index e97e13c22..2d66ea410 100644 --- a/backend/filelu/filelu.go +++ b/backend/filelu/filelu.go @@ -222,38 +222,36 @@ func (f *Fs) List(ctx context.Context, dir string) (fs.DirEntries, error) { return nil, err } - fldMap := map[string]bool{} for _, folder := range result.Result.Folders { - fldMap[folder.FldID.String()] = true if f.root == "" && dir == "" && strings.Contains(folder.Path, "/") { continue } - paths := strings.Split(folder.Path, fullPath+"/") - remote := paths[0] - if len(paths) > 1 { - remote = paths[1] + folderPath := strings.Trim(folder.Path, "/") + root := strings.Trim(f.root, "/") + + remotePathWithoutRoot := folderPath + + if root != "" { + if remotePathWithoutRoot == root { + continue + } + remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, root+"/") } - if strings.Contains(remote, "/") { + remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, "/") + + if remotePathWithoutRoot == "" { continue } - pathsWithoutRoot := strings.Split(folder.Path, "/"+f.root+"/") - remotePathWithoutRoot := pathsWithoutRoot[0] - if len(pathsWithoutRoot) > 1 { - remotePathWithoutRoot = pathsWithoutRoot[1] - } - remotePathWithoutRoot = strings.TrimPrefix(remotePathWithoutRoot, "/") entries = append(entries, fs.NewDir(remotePathWithoutRoot, time.Now())) } + for _, file := range result.Result.Files { - if _, ok := fldMap[file.FldID.String()]; ok { - continue - } remote := path.Join(dir, file.Name) - // trim leading slashes remote = strings.TrimPrefix(remote, "/") + obj := &Object{ fs: f, remote: remote,