Set direct sqlite storage conn to nil on close

This might help catch the reason for SQLITE_MISUSE in getCapacity.
This commit is contained in:
Matt Joiner 2021-08-18 16:56:05 +10:00
parent 092dc74458
commit 8a65ef627d
1 changed files with 7 additions and 3 deletions

View File

@ -114,15 +114,19 @@ func (c *client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (stora
return storage.TorrentImpl{Piece: t.Piece, Close: t.Close, Capacity: &c.capacity}, nil
}
func (c *client) Close() error {
func (c *client) Close() (err error) {
c.l.Lock()
defer c.l.Unlock()
c.flushBlobs()
c.closed = true
if c.opts.BlobFlushInterval != 0 {
c.blobFlusher.Stop()
}
return c.conn.Close()
if !c.closed {
c.closed = true
err = c.conn.Close()
c.conn = nil
}
return
}
type torrent struct {