]> Sergey Matveev's repositories - btrtrc.git/commitdiff
use path.utf8 first for some torrent (#350)
authorYates <xy.boad@hotmail.com>
Sun, 8 Dec 2019 09:35:40 +0000 (17:35 +0800)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 8 Dec 2019 09:35:40 +0000 (20:35 +1100)
metainfo/fileinfo.go
t.go

index 4b72d12d81edbae8879edd1ac9794b6e1b0ed0b2..58073a1bbf715a07877fbc8bd0cf517cde7319fa 100644 (file)
@@ -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 6b553f96e34ec88593ac12cb119fc7104dc03db3..92a265f15bcee20b4a4d7d23db3bdd50cfa78c2d 100644 (file)
--- 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,