From 790ba6af3c9ee50f4a42c1f128d391b473b96088 Mon Sep 17 00:00:00 2001 From: Yates Date: Sun, 8 Dec 2019 17:35:40 +0800 Subject: [PATCH] use path.utf8 first for some torrent (#350) --- metainfo/fileinfo.go | 5 +++-- t.go | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/metainfo/fileinfo.go b/metainfo/fileinfo.go index 4b72d12d..58073a1b 100644 --- a/metainfo/fileinfo.go +++ b/metainfo/fileinfo.go @@ -4,8 +4,9 @@ import "strings" // Information specific to a single file inside the MetaInfo structure. type FileInfo struct { - Length int64 `bencode:"length"` - Path []string `bencode:"path"` + Length int64 `bencode:"length"` + Path []string `bencode:"path"` + PathUTF8 []string `bencode:"path.utf-8,omitempty"` } func (fi *FileInfo) DisplayPath(info *Info) string { diff --git a/t.go b/t.go index 6b553f96..92a265f1 100644 --- a/t.go +++ b/t.go @@ -189,9 +189,15 @@ func (t *Torrent) initFiles() { var offset int64 t.files = new([]*File) for _, fi := range t.info.UpvertedFiles() { + var path []string + if len(fi.PathUTF8) != 0 { + path = fi.PathUTF8 + } else { + path = fi.Path + } *t.files = append(*t.files, &File{ t, - strings.Join(append([]string{t.info.Name}, fi.Path...), "/"), + strings.Join(append([]string{t.info.Name}, path...), "/"), offset, fi.Length, fi, -- 2.44.0