#! /bin/sh /usr/share/dpatch/dpatch-run ## 20_tracker_cache_minor_fix.dpatch by ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix a minor bug in the tracker's new cache structure. ## DP: Fix is taken from upstream CVS. @DPATCH@ --- bittornado.orig/BitTornado/BT1/track.py +++ bittornado/BitTornado/BT1/track.py @@ -688,15 +688,19 @@ self.seedcount[infohash] += 1 if not peer.get('nat', -1): for bc in self.becache[infohash]: - bc[1][myid] = bc[0][myid] - del bc[0][myid] + x = bc[0].get(myid) + if x: + bc[1][myid] = x + del bc[0][myid] elif left and not peer['left']: self.completed[infohash] -= 1 self.seedcount[infohash] -= 1 if not peer.get('nat', -1): for bc in self.becache[infohash]: - bc[0][myid] = bc[1][myid] - del bc[1][myid] + x = bc[1].get(myid) + if x: + bc[0][myid] = x + del bc[1][myid] peer['left'] = left if port: @@ -717,7 +721,8 @@ l = self.becache[infohash] y = not peer['left'] for x in l: - del x[y][myid] + if x[y].has_key(myid): + del x[y][myid] if natted >= 0: del peer['nat'] # restart NAT testing if natted and natted < self.natcheck: