From: Matt Joiner Date: Tue, 15 Mar 2022 02:42:00 +0000 (+1100) Subject: Export Torrent.UseSources X-Git-Tag: v1.42.0~13 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=55b178a8ca174fb4e7f850cae60e0ca665e5cc19;p=btrtrc.git Export Torrent.UseSources --- diff --git a/client.go b/client.go index a6b6b216..275a267f 100644 --- a/client.go +++ b/client.go @@ -1312,10 +1312,10 @@ func (t *Torrent) MergeSpec(spec *TorrentSpec) error { } cl := t.cl cl.AddDhtNodes(spec.DhtNodes) + t.UseSources(spec.Sources) cl.lock() defer cl.unlock() t.initialPieceCheckDisabled = spec.DisableInitialPieceCheck - t.useSources(spec.Sources) for _, url := range spec.Webseeds { t.addWebSeed(url) } diff --git a/sources.go b/sources.go index 4fd44673..a03b7675 100644 --- a/sources.go +++ b/sources.go @@ -10,7 +10,9 @@ import ( "github.com/anacrolix/torrent/metainfo" ) -func (t *Torrent) useSources(sources []string) { +// Add HTTP endpoints that serve the metainfo. They will be used if the torrent info isn't obtained +// yet. The Client HTTP client is used. +func (t *Torrent) UseSources(sources []string) { select { case <-t.Closed(): return