client.go | 4 ++-- cmd/magnet-metainfo/main.go | 2 +- cmd/torrent/main.go | 2 +- t.go | 11 +++++++---- diff --git a/client.go b/client.go index 14205d8994fa35dc4151fd7417dc8d216cc641c2..64483a39c95c95b6cd0bbbdcc1ad042f5e3e554d 100644 --- a/client.go +++ b/client.go @@ -643,7 +643,7 @@ t, ok := cl.torrents[ih] if !ok { return } - T = Torrent{cl, t, t.gotMetainfo} + T = Torrent{cl, t} return } @@ -2612,7 +2612,7 @@ // Returns handles to all the torrents loaded in the Client. func (me *Client) Torrents() (ret []Torrent) { me.mu.Lock() for _, t := range me.torrents { - ret = append(ret, Torrent{me, t, t.gotMetainfo}) + ret = append(ret, Torrent{me, t}) } me.mu.Unlock() return diff --git a/cmd/magnet-metainfo/main.go b/cmd/magnet-metainfo/main.go index da94532ebd383d45fc50b8b98a41874d69f19e6e..878fc7db9404c81445c57325b9a2ce16bde88982 100644 --- a/cmd/magnet-metainfo/main.go +++ b/cmd/magnet-metainfo/main.go @@ -26,7 +26,7 @@ } wg.Add(1) go func() { defer wg.Done() - <-t.GotInfo + <-t.GotInfo() mi := t.MetaInfo() t.Drop() f, err := os.Create(mi.Info.Name + ".torrent") diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index dcb46914cc5a6c4705aadbf1b93c278823b84821..d81d219ed8ceb65cc13e0cf533c882b2146b9eb4 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -128,7 +128,7 @@ if err != nil { log.Fatal(err) } go func() { - <-t.GotInfo + <-t.GotInfo() t.DownloadAll() }() } diff --git a/t.go b/t.go index a4cf064f115ba14f92c7592c32acb184d3cd8eb6..70e6f8dd42affed6990582404a9b24693eaf8e5a 100644 --- a/t.go +++ b/t.go @@ -10,10 +10,13 @@ // A handle to a live torrent within a Client. type Torrent struct { cl *Client *torrent - // Closed when the info (.Info()) for the torrent has become available. - // Using features of Torrent that require the info before it is available - // will have undefined behaviour. - GotInfo <-chan struct{} +} + +// Closed when the info (.Info()) for the torrent has become available. Using +// features of Torrent that require the info before it is available will have +// undefined behaviour. +func (t *Torrent) GotInfo() <-chan struct{} { + return t.torrent.gotMetainfo } func (t *Torrent) Info() *metainfo.Info {