]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add AddTorrentOpts.InfoBytes
authorMatt Joiner <anacrolix@gmail.com>
Tue, 4 Apr 2023 09:12:01 +0000 (19:12 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 4 Apr 2023 09:12:01 +0000 (19:12 +1000)
client.go

index 4d6761a8582e7e46beb14fc96d59efa74f18dfcb..7524cb0f600fab9c76893df9df1dbf000844f58e 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1259,9 +1259,8 @@ func (cl *Client) AddTorrentInfoHashWithStorage(infoHash metainfo.Hash, specStor
        return
 }
 
-// Adds a torrent by InfoHash with a custom Storage implementation.
-// If the torrent already exists then this Storage is ignored and the
-// existing torrent returned with `new` set to `false`
+// Adds a torrent by InfoHash with a custom Storage implementation. If the torrent already exists
+// then this Storage is ignored and the existing torrent returned with `new` set to `false`.
 func (cl *Client) AddTorrentOpt(opts AddTorrentOpts) (t *Torrent, new bool) {
        infoHash := opts.InfoHash
        cl.lock()
@@ -1279,6 +1278,7 @@ func (cl *Client) AddTorrentOpt(opts AddTorrentOpts) (t *Torrent, new bool) {
                }
        })
        cl.torrents[infoHash] = t
+       t.setInfoBytesLocked(opts.InfoBytes)
        cl.clearAcceptLimits()
        t.updateWantPeersEvent()
        // Tickle Client.waitAccept, new torrent may want conns.
@@ -1290,6 +1290,7 @@ type AddTorrentOpts struct {
        InfoHash  infohash.T
        Storage   storage.ClientImpl
        ChunkSize pp.Integer
+       InfoBytes []byte
 }
 
 // Add or merge a torrent spec. Returns new if the torrent wasn't already in the client. See also