]> Sergey Matveev's repositories - btrtrc.git/commitdiff
newTorrent doesn't need to return error
authorMatt Joiner <anacrolix@gmail.com>
Sun, 31 Jan 2016 20:05:43 +0000 (07:05 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 31 Jan 2016 20:05:43 +0000 (07:05 +1100)
client.go
client_test.go

index c4ea5bd32430df779718782f5a7f93968145b43c..ed81c0c993568bc518aaf105f697d4a2db77885c 100644 (file)
--- a/client.go
+++ b/client.go
@@ -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
 // initialize fields all fields that don't require the Client without locking
 // it.
-func newTorrent(ih InfoHash) (t *torrent, err error) {
+func newTorrent(ih InfoHash) (t *torrent) {
        t = &torrent{
                InfoHash:  ih,
                chunkSize: defaultChunkSize,
@@ -2057,11 +2057,8 @@ func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (T Torrent, new bool, err er
                        err = errors.New("banned torrent")
                        return
                }
-
-               t, err = newTorrent(spec.InfoHash)
-               if err != nil {
-                       return
-               }
+               // TODO: Tidy this up?
+               t = newTorrent(spec.InfoHash)
                if spec.ChunkSize != 0 {
                        t.chunkSize = pp.Integer(spec.ChunkSize)
                }
index 5d0c75273213e5bd44c8c79ddcdc1dda264ec9e1..41bc0a3dfe67924c267df041daa6dab43779076e 100644 (file)
@@ -95,15 +95,12 @@ func TestPieceHashSize(t *testing.T) {
 func TestTorrentInitialState(t *testing.T) {
        dir, mi := testutil.GreetingTestTorrent()
        defer os.RemoveAll(dir)
-       tor, err := newTorrent(func() (ih InfoHash) {
+       tor := newTorrent(func() (ih InfoHash) {
                missinggo.CopyExact(ih[:], mi.Info.Hash)
                return
        }())
-       if err != nil {
-               t.Fatal(err)
-       }
        tor.chunkSize = 2
-       err = tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
+       err := tor.setMetadata(&mi.Info.Info, mi.Info.Bytes)
        if err != nil {
                t.Fatal(err)
        }