From 4a31dffa95c88e15e6f06bfa892d2ba3a5e4e344 Mon Sep 17 00:00:00 2001 From: Radoslav Georgiev Date: Tue, 16 Apr 2019 23:28:10 +0300 Subject: [PATCH] torrentfs: fix a bug where the basenames of files are extracted incorrectly when listing the entries in a directory --- fs/torrentfs.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/torrentfs.go b/fs/torrentfs.go index 1bcc85fa..47dfffc0 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -78,10 +78,17 @@ func isSubPath(parent, child string) bool { func (dn dirNode) ReadDirAll(ctx context.Context) (des []fuse.Dirent, err error) { names := map[string]bool{} for _, fi := range dn.metadata.Files { - if !isSubPath(dn.path, strings.Join(fi.Path, "/")) { + filePathname := strings.Join(fi.Path, "/") + if !isSubPath(dn.path, filePathname) { continue } - name := fi.Path[len(dn.path)] + var name string + if dn.path == "" { + name = fi.Path[0] + } else { + dirPathname := strings.Split(dn.path, "/") + name = fi.Path[len(dirPathname)] + } if names[name] { continue } -- 2.48.1