TrackerShare: move the tracker list cleanup code from getSupportedProtocols() to a separate method
This commit is contained in:
parent
0d02c3c4da
commit
cb363d2f11
1 changed files with 9 additions and 6 deletions
|
@ -96,12 +96,7 @@ class TrackerStorage(object):
|
||||||
|
|
||||||
return protocol
|
return protocol
|
||||||
|
|
||||||
def getSupportedProtocols(self):
|
def deleteUnusedTrackers(self, supported_trackers):
|
||||||
if not self.site_announcer:
|
|
||||||
return None
|
|
||||||
|
|
||||||
supported_trackers = self.site_announcer.getSupportedTrackers()
|
|
||||||
|
|
||||||
# If a tracker is in our list, but is absent from the results of getSupportedTrackers(),
|
# If a tracker is in our list, but is absent from the results of getSupportedTrackers(),
|
||||||
# it seems to be supported by software, but forbidden by the settings or network configuration.
|
# it seems to be supported by software, but forbidden by the settings or network configuration.
|
||||||
# We check and remove thoose trackers here, since onTrackerError() is never emitted for them.
|
# We check and remove thoose trackers here, since onTrackerError() is never emitted for them.
|
||||||
|
@ -113,6 +108,14 @@ class TrackerStorage(object):
|
||||||
self.log.info("Tracker %s looks unused, removing." % tracker_address)
|
self.log.info("Tracker %s looks unused, removing." % tracker_address)
|
||||||
del trackers[tracker_address]
|
del trackers[tracker_address]
|
||||||
|
|
||||||
|
def getSupportedProtocols(self):
|
||||||
|
if not self.site_announcer:
|
||||||
|
return None
|
||||||
|
|
||||||
|
supported_trackers = self.site_announcer.getSupportedTrackers()
|
||||||
|
|
||||||
|
self.deleteUnusedTrackers(supported_trackers)
|
||||||
|
|
||||||
protocols = set()
|
protocols = set()
|
||||||
for tracker_address in supported_trackers:
|
for tracker_address in supported_trackers:
|
||||||
protocol = self.getNormalizedTrackerProtocol(tracker_address)
|
protocol = self.getNormalizedTrackerProtocol(tracker_address)
|
||||||
|
|
Loading…
Reference in a new issue