From: Radoslav Georgiev Date: Tue, 16 Apr 2019 20:28:10 +0000 (+0300) Subject: torrentfs: fix a bug where the basenames of files are extracted incorrectly when... X-Git-Tag: v1.1.4~1 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4a31dffa95c88e15e6f06bfa892d2ba3a5e4e344;p=btrtrc.git torrentfs: fix a bug where the basenames of files are extracted incorrectly when listing the entries in a directory --- 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 }