From: Yates Date: Sun, 8 Dec 2019 09:35:40 +0000 (+0800) Subject: use path.utf8 first for some torrent (#350) X-Git-Tag: v1.10.0~1 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=790ba6af3c9ee50f4a42c1f128d391b473b96088;p=btrtrc.git use path.utf8 first for some torrent (#350) --- 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,