X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=spec.go;h=8cce3cb326f1ff3594b921338804f381d5a7e7cd;hb=963c0e0f3299ce47fc44cda8b9dead59ff7eea2b;hp=a69e2093d9e386d406f9c95831f17ee00876e874;hpb=d19079e69899016c08c993d07431be9e2cd51f0a;p=btrtrc.git diff --git a/spec.go b/spec.go index a69e2093..8cce3cb3 100644 --- a/spec.go +++ b/spec.go @@ -19,9 +19,11 @@ type TorrentSpec struct { InfoBytes []byte // The name to use if the Name field from the Info isn't available. DisplayName string - Webseeds []string - DhtNodes []string - PeerAddrs []string + // WebSeed URLs. For additional options add the URLs separately with Torrent.AddWebSeeds + // instead. + Webseeds []string + DhtNodes []string + PeerAddrs []string // The combination of the "xs" and "as" fields in magnet links, for now. Sources []string @@ -30,7 +32,7 @@ type TorrentSpec struct { ChunkSize pp.Integer // TODO: Move into a "new" Torrent opt type. Storage storage.ClientImpl - + DisableInitialPieceCheck bool // Whether to allow data download or upload @@ -55,10 +57,12 @@ func TorrentSpecFromMagnetUri(uri string) (spec *TorrentSpec, err error) { return } +// The error will be from unmarshalling the info bytes. The TorrentSpec is still filled out as much +// as possible in this case. func TorrentSpecFromMetaInfoErr(mi *metainfo.MetaInfo) (*TorrentSpec, error) { info, err := mi.UnmarshalInfo() if err != nil { - return nil, fmt.Errorf("unmarshalling info: %w", err) + err = fmt.Errorf("unmarshalling info: %w", err) } return &TorrentSpec{ Trackers: mi.UpvertedAnnounceList(), @@ -73,9 +77,10 @@ func TorrentSpecFromMetaInfoErr(mi *metainfo.MetaInfo) (*TorrentSpec, error) { } return }(), - }, nil + }, err } +// Panics if there was anything missing from the metainfo. func TorrentSpecFromMetaInfo(mi *metainfo.MetaInfo) *TorrentSpec { ts, err := TorrentSpecFromMetaInfoErr(mi) if err != nil {