storage/boltPieceCompletion.go | 1 + storage/boltdb.go | 15 ++++++++------- diff --git a/storage/boltPieceCompletion.go b/storage/boltPieceCompletion.go index 93cf8d6f666da0a033201edb958841028c694365..d0accb1df7da225184616b8cd1d68541adeb86b6 100644 --- a/storage/boltPieceCompletion.go +++ b/storage/boltPieceCompletion.go @@ -35,6 +35,7 @@ }) if err != nil { return } + db.NoSync = true ret = &boltPieceCompletion{db} return } diff --git a/storage/boltdb.go b/storage/boltdb.go index 6c8de430d6ca7aa1e0a596a7d53ba505e3a8fd4e..6586ff0e3c009628554b093f8964bb615d14819c 100644 --- a/storage/boltdb.go +++ b/storage/boltdb.go @@ -3,7 +3,9 @@ import ( "encoding/binary" "path/filepath" + "time" + "github.com/anacrolix/missinggo/assert" "github.com/boltdb/bolt" "github.com/anacrolix/torrent/metainfo" @@ -25,13 +27,12 @@ ih metainfo.Hash } func NewBoltDB(filePath string) ClientImpl { - ret := &boltDBClient{} - var err error - ret.db, err = bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, nil) - if err != nil { - panic(err) - } - return ret + db, err := bolt.Open(filepath.Join(filePath, "bolt.db"), 0600, &bolt.Options{ + Timeout: time.Second, + }) + assert.Nil(err) + db.NoSync = true + return &boltDBClient{db} } func (me *boltDBClient) Close() error {