From: Matt Joiner Date: Tue, 14 Jun 2022 00:06:36 +0000 (+1000) Subject: internal/testutil.Info: Support multi-file Torrents X-Git-Tag: v1.45.0~8 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=caf35cd9b8af201297c0447149f533da04c8daa2;p=btrtrc.git internal/testutil.Info: Support multi-file Torrents --- diff --git a/internal/testutil/spec.go b/internal/testutil/spec.go index b2daa48b..42d91ba3 100644 --- a/internal/testutil/spec.go +++ b/internal/testutil/spec.go @@ -44,6 +44,13 @@ func (t *Torrent) Info(pieceLength int64) metainfo.Info { } if t.IsDir() { info.Length = int64(len(t.Files[0].Data)) + } else { + for _, f := range t.Files { + info.Files = append(info.Files, metainfo.FileInfo{ + Path: []string{f.Name}, + Length: int64(len(f.Data)), + }) + } } err := info.GeneratePieces(func(fi metainfo.FileInfo) (io.ReadCloser, error) { return ioutil.NopCloser(strings.NewReader(t.GetFile(strings.Join(fi.Path, "/")).Data)), nil