Update append trackers commit to ignore state file adds

This commit is contained in:
Calum Lind 2011-06-28 01:42:26 +01:00
parent 6ad3a770af
commit 2cceb3a349
1 changed files with 23 additions and 22 deletions

View File

@ -410,31 +410,32 @@ class TorrentManager(component.Component):
add_torrent_params["duplicate_is_error"] = True add_torrent_params["duplicate_is_error"] = True
# If torrent already exists just append any extra trackers. # If torrent already exists just append any extra trackers.
add_torrent_id = str(add_torrent_params["ti"].info_hash()) if state is None:
if add_torrent_id in self.get_torrent_list(): add_torrent_id = str(add_torrent_params["ti"].info_hash())
log.debug("Torrent (%s) exists, checking for trackers to add...", add_torrent_id) if add_torrent_id in self.get_torrent_list():
add_torrent_trackers = [] log.debug("Torrent (%s) exists, checking for trackers to add...", add_torrent_id)
for value in add_torrent_params["ti"].trackers(): add_torrent_trackers = []
tracker = {} for value in add_torrent_params["ti"].trackers():
tracker["url"] = value.url tracker = {}
tracker["tier"] = value.tier tracker["url"] = value.url
add_torrent_trackers.append(tracker) tracker["tier"] = value.tier
add_torrent_trackers.append(tracker)
torrent_trackers = {} torrent_trackers = {}
tracker_list = [] tracker_list = []
for tracker in self[add_torrent_id].get_status(["trackers"])["trackers"]: for tracker in self[add_torrent_id].get_status(["trackers"])["trackers"]:
torrent_trackers[(tracker["url"])] = tracker torrent_trackers[(tracker["url"])] = tracker
tracker_list.append(tracker)
added_tracker = False
for tracker in add_torrent_trackers:
if tracker['url'] not in torrent_trackers:
tracker_list.append(tracker) tracker_list.append(tracker)
added_tracker = True
if added_tracker: added_tracker = False
self[add_torrent_id].set_trackers(tracker_list) for tracker in add_torrent_trackers:
return if tracker['url'] not in torrent_trackers:
tracker_list.append(tracker)
added_tracker = True
if added_tracker:
self[add_torrent_id].set_trackers(tracker_list)
return
# We need to pause the AlertManager momentarily to prevent alerts # We need to pause the AlertManager momentarily to prevent alerts
# for this torrent being generated before a Torrent object is created. # for this torrent being generated before a Torrent object is created.