From f74ef67d08b2857562f731ccf18215fc97f0fc74 Mon Sep 17 00:00:00 2001 From: Paul Saab Date: Wed, 24 Sep 2014 12:55:24 -0700 Subject: [PATCH] Only decrement torrent map size if hash exists --- tracker/storage.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tracker/storage.go b/tracker/storage.go index 8aa1522..9afeb18 100644 --- a/tracker/storage.go +++ b/tracker/storage.go @@ -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 {