]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix nil context being passed to function
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Mon, 7 Jun 2021 03:24:32 +0000 (03:24 +0000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 7 Jun 2021 09:32:02 +0000 (19:32 +1000)
storage/sqlite/sqlite-storage.go
storage/sqlite/sqlite-storage_test.go

index 38f734fe5096f4d54a04d475620279dbf004800c..9eb97e85abceac600b67a41f251c8737be19e78f 100644 (file)
@@ -252,7 +252,7 @@ func NewPiecesStorage(opts NewPiecesStorageOpts) (_ storage.ClientImplCloser, er
        if opts.SetJournalMode == "" && !opts.Memory {
                opts.SetJournalMode = "wal"
        }
-       err = initPoolConns(nil, conns, opts.InitConnOpts)
+       err = initPoolConns(context.TODO(), conns, opts.InitConnOpts)
        if err != nil {
                conns.Close()
                return
@@ -494,7 +494,7 @@ type ConnPool interface {
 }
 
 func withPoolConn(pool ConnPool, with func(conn)) {
-       c := pool.Get(nil)
+       c := pool.Get(context.TODO())
        defer pool.Put(c)
        with(c)
 }
index 2494ce6d1a7602e925afa41cc95b2752a5a49c43..1fe1314ea3e1cc442f5045801864d2dfb2463701 100644 (file)
@@ -5,6 +5,7 @@ package sqliteStorage
 
 import (
        "bytes"
+       "context"
        "errors"
        "fmt"
        "io"
@@ -34,7 +35,7 @@ func newConnsAndProv(t *testing.T, opts NewPoolOpts) (ConnPool, *provider) {
        if !opts.Memory && opts.SetJournalMode == "" {
                opts.SetJournalMode = "wal"
        }
-       qt.Assert(t, initPoolConns(nil, pool, opts.InitConnOpts), qt.IsNil)
+       qt.Assert(t, initPoolConns(context.TODO(), pool, opts.InitConnOpts), qt.IsNil)
        prov, err := NewProvider(pool, ProviderOpts{BatchWrites: pool.NumConns() > 1})
        require.NoError(t, err)
        t.Cleanup(func() { prov.Close() })