Only decrement torrent map size if hash exists

This commit is contained in:
Paul Saab 2014-09-24 12:55:24 -07:00
parent 9fea8195bb
commit f74ef67d08

View file

@ -101,8 +101,10 @@ func (s *Storage) DeleteTorrent(infohash string) {
shard := s.GetTorrentShard(infohash, false)
defer shard.Unlock()
atomic.AddInt32(&s.size, -1)
delete(shard.torrents, infohash)
if _, exists := shard.torrents[infohash]; exists {
atomic.AddInt32(&s.size, -1)
delete(shard.torrents, infohash)
}
}
func (s *Storage) IncrementTorrentSnatches(infohash string) error {