From caf35cd9b8af201297c0447149f533da04c8daa2 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 14 Jun 2022 10:06:36 +1000 Subject: [PATCH] internal/testutil.Info: Support multi-file Torrents --- internal/testutil/spec.go | 7 +++++++ 1 file changed, 7 insertions(+) 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