From c04f09ee4296d6404ff9b336c9c5b106f62dfad5 Mon Sep 17 00:00:00 2001
From: Matt Joiner <anacrolix@gmail.com>
Date: Thu, 21 May 2020 12:17:10 +1000
Subject: [PATCH] Fix panic closing torrent that failed to open storage

---
 storage/wrappers.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/storage/wrappers.go b/storage/wrappers.go
index da52c89f..97f52c00 100644
--- a/storage/wrappers.go
+++ b/storage/wrappers.go
@@ -19,7 +19,10 @@ func NewClient(cl ClientImpl) *Client {
 
 func (cl Client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (*Torrent, error) {
 	t, err := cl.ci.OpenTorrent(info, infoHash)
-	return &Torrent{t}, err
+	if err != nil {
+		return nil, err
+	}
+	return &Torrent{t}, nil
 }
 
 type Torrent struct {
-- 
2.51.0