X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=sources.go;h=ed5ecbfa6c0b492884aaa60e55b222ce9d5ecf7d;hb=HEAD;hp=4fd44673e41b2cc0c5e0ae2122dbef43db17c7e7;hpb=bf81f4a528685dc11ab67b35126f6b28dcb040be;p=btrtrc.git diff --git a/sources.go b/sources.go index 4fd44673..ed5ecbfa 100644 --- a/sources.go +++ b/sources.go @@ -2,15 +2,19 @@ package torrent import ( "context" + "errors" "fmt" "net/http" "github.com/anacrolix/log" + "github.com/anacrolix/torrent/bencode" "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 @@ -31,7 +35,7 @@ func (t *Torrent) useSources(sources []string) { panic(s) } level := log.Debug - if err != nil { + if err != nil && !errors.Is(err, context.Canceled) { level = log.Warning } t.logger.Levelf(level, "used torrent source %q [err=%v]", s, err)