Merge pull request #2 from Charroja/deepsource-fix-436d8fe4

Remove unnecessary guard around `delete`
This commit is contained in:
Charroja
2021-05-03 22:41:19 +03:00
committed by GitHub
2 changed files with 2 additions and 6 deletions

View File

@@ -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()

View File

@@ -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()