Prevent private flagged torrents auto-merging trackers

When adding a torrent already in session any new trackers are merged
to the exiting torrent but this is an unwanted feature for private
flagged torrents.
This commit is contained in:
Calum Lind 2014-07-07 23:25:57 +01:00
parent 59fa974b3b
commit 34650f4b3c

View File

@ -382,9 +382,14 @@ class TorrentManager(component.Component):
# We have a torrent_info object or magnet uri so we're not loading from state.
if torrent_info:
add_torrent_id = str(torrent_info.info_hash())
# If this torrent id is already in the session, merge any additional trackers.
if add_torrent_id in self.get_torrent_list():
# Torrent already exists just append any extra trackers.
log.debug("Torrent (%s) exists, checking for trackers to add...", add_torrent_id)
log.info("Merging trackers for torrent (%s) already in session...", add_torrent_id)
# Don't merge trackers if either torrent has private flag set
if self[add_torrent_id].get_status(["private"])["private"]:
log.info("Merging trackers abandoned: Torrent has private flag set.")
return
add_torrent_trackers = []
for value in torrent_info.trackers():
tracker = {}
@ -398,13 +403,14 @@ class TorrentManager(component.Component):
torrent_trackers[(tracker["url"])] = tracker
tracker_list.append(tracker)
added_tracker = False
added_tracker = 0
for tracker in add_torrent_trackers:
if tracker['url'] not in torrent_trackers:
tracker_list.append(tracker)
added_tracker = True
added_tracker += 1
if added_tracker:
log.info("%s tracker(s) merged into torrent.", added_tracker)
self[add_torrent_id].set_trackers(tracker_list)
return