From 99fa7301cb35762d157e4b5c64668c3f7b8efcf6 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Mon, 3 May 2021 19:40:36 +0000 Subject: [PATCH] Remove unnecessary guard around `delete` --- server/torr/storage/torrstor/cache.go | 4 +--- server/torr/torrent.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index 07a8418..4d929ec 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -80,9 +80,7 @@ func (c *Cache) Piece(m metainfo.Piece) storage.PieceImpl { func (c *Cache) Close() error { log.TLogln("Close cache for:", c.hash) - if _, ok := c.storage.caches[c.hash]; ok { - delete(c.storage.caches, c.hash) - } + delete(c.storage.caches, c.hash) c.pieces = nil c.muReaders.Lock() diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 11ac52a..27f8eeb 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -359,9 +359,7 @@ func (t *Torrent) Close() { t.Stat = state.TorrentClosed t.bt.mu.Lock() - if _, ok := t.bt.torrents[t.Hash()]; ok { - delete(t.bt.torrents, t.Hash()) - } + delete(t.bt.torrents, t.Hash()) t.bt.mu.Unlock() t.drop()