Merge pull request #48 from Charroja/master

Fix anti-pattern
This commit is contained in:
YouROK
2021-05-07 22:38:31 +03:00
committed by GitHub
5 changed files with 6 additions and 11 deletions

View File

@@ -82,9 +82,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()