diff --git a/client.go b/client.go index 14205d89..64483a39 100644 --- a/client.go +++ b/client.go @@ -643,7 +643,7 @@ func (cl *Client) Torrent(ih InfoHash) (T Torrent, ok bool) { if !ok { return } - T = Torrent{cl, t, t.gotMetainfo} + T = Torrent{cl, t} return } @@ -2612,7 +2612,7 @@ func (cl *Client) verifyPiece(t *torrent, index pp.Integer) { 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 da94532e..878fc7db 100644 --- a/cmd/magnet-metainfo/main.go +++ b/cmd/magnet-metainfo/main.go @@ -26,7 +26,7 @@ func main() { 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 dcb46914..d81d219e 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -128,7 +128,7 @@ func main() { log.Fatal(err) } go func() { - <-t.GotInfo + <-t.GotInfo() t.DownloadAll() }() } diff --git a/t.go b/t.go index a4cf064f..70e6f8dd 100644 --- a/t.go +++ b/t.go @@ -10,10 +10,13 @@ import ( 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 {