newTorrent doesn't need to return error
This commit is contained in:
parent
b90dacd324
commit
eb838a894c
|
@ -1842,7 +1842,7 @@ func (cl *Client) setMetaData(t *torrent, md *metainfo.Info, bytes []byte) (err
|
||||||
// Prepare a Torrent without any attachment to a Client. That means we can
|
// Prepare a Torrent without any attachment to a Client. That means we can
|
||||||
// initialize fields all fields that don't require the Client without locking
|
// initialize fields all fields that don't require the Client without locking
|
||||||
// it.
|
// it.
|
||||||
func newTorrent(ih InfoHash) (t *torrent, err error) {
|
func newTorrent(ih InfoHash) (t *torrent) {
|
||||||
t = &torrent{
|
t = &torrent{
|
||||||
InfoHash: ih,
|
InfoHash: ih,
|
||||||
chunkSize: defaultChunkSize,
|
chunkSize: defaultChunkSize,
|
||||||
|
@ -2057,11 +2057,8 @@ func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (T Torrent, new bool, err er
|
||||||
err = errors.New("banned torrent")
|
err = errors.New("banned torrent")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// TODO: Tidy this up?
|
||||||
t, err = newTorrent(spec.InfoHash)
|
t = newTorrent(spec.InfoHash)
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if spec.ChunkSize != 0 {
|
if spec.ChunkSize != 0 {
|
||||||
t.chunkSize = pp.Integer(spec.ChunkSize)
|
t.chunkSize = pp.Integer(spec.ChunkSize)
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,15 +95,12 @@ func TestPieceHashSize(t *testing.T) {
|
||||||
func TestTorrentInitialState(t *testing.T) {
|
func TestTorrentInitialState(t *testing.T) {
|
||||||
dir, mi := testutil.GreetingTestTorrent()
|
dir, mi := testutil.GreetingTestTorrent()
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
tor, err := newTorrent(func() (ih InfoHash) {
|
tor := newTorrent(func() (ih InfoHash) {
|
||||||
missinggo.CopyExact(ih[:], mi.Info.Hash)
|
missinggo.CopyExact(ih[:], mi.Info.Hash)
|
||||||
return
|
return
|
||||||
}())
|
}())
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
tor.chunkSize = 2
|
tor.chunkSize = 2
|
||||||
err = tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
|
err := tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue