[Core] Workaround unwanted tracker announce when force rechecking paused torrent
* This workaround updates the stored torrent.trackers, sets empty handle.trackers then resets trackers after pausing.
This commit is contained in:
parent
099a4eb8c6
commit
20088a5c70
|
@ -323,7 +323,7 @@ class Torrent(object):
|
||||||
# Set the first/last priorities if needed
|
# Set the first/last priorities if needed
|
||||||
self.set_prioritize_first_last(self.options["prioritize_first_last_pieces"])
|
self.set_prioritize_first_last(self.options["prioritize_first_last_pieces"])
|
||||||
|
|
||||||
def set_trackers(self, trackers):
|
def set_trackers(self, trackers, reannounce=True):
|
||||||
"""Sets trackers"""
|
"""Sets trackers"""
|
||||||
if trackers == None:
|
if trackers == None:
|
||||||
trackers = []
|
trackers = []
|
||||||
|
@ -353,7 +353,7 @@ class Torrent(object):
|
||||||
# log.debug("tier: %s tracker: %s", t["tier"], t["url"])
|
# log.debug("tier: %s tracker: %s", t["tier"], t["url"])
|
||||||
# Set the tracker list in the torrent object
|
# Set the tracker list in the torrent object
|
||||||
self.trackers = trackers
|
self.trackers = trackers
|
||||||
if len(trackers) > 0:
|
if len(trackers) > 0 and reannounce:
|
||||||
# Force a reannounce if there is at least 1 tracker
|
# Force a reannounce if there is at least 1 tracker
|
||||||
self.force_reannounce()
|
self.force_reannounce()
|
||||||
|
|
||||||
|
@ -926,16 +926,22 @@ class Torrent(object):
|
||||||
|
|
||||||
def force_recheck(self):
|
def force_recheck(self):
|
||||||
"""Forces a recheck of the torrents pieces"""
|
"""Forces a recheck of the torrents pieces"""
|
||||||
paused = self.handle.is_paused()
|
self.forcing_recheck = True
|
||||||
|
self.forcing_recheck_paused = self.handle.is_paused()
|
||||||
|
# Store trackers for paused torrents to prevent unwanted announce before pausing again.
|
||||||
|
if self.forcing_recheck_paused:
|
||||||
|
self.set_trackers(None, reannounce=False)
|
||||||
|
self.handle.replace_trackers([])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.handle.force_recheck()
|
self.handle.force_recheck()
|
||||||
self.handle.resume()
|
self.handle.resume()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug("Unable to force recheck: %s", e)
|
log.debug("Unable to force recheck: %s", e)
|
||||||
return False
|
self.forcing_recheck = False
|
||||||
self.forcing_recheck = True
|
self.set_trackers(torrent.trackers, reannounce=False)
|
||||||
self.forcing_recheck_paused = paused
|
|
||||||
return True
|
return self.forcing_recheck
|
||||||
|
|
||||||
def rename_files(self, filenames):
|
def rename_files(self, filenames):
|
||||||
"""Renames files in the torrent. 'filenames' should be a list of
|
"""Renames files in the torrent. 'filenames' should be a list of
|
||||||
|
|
|
@ -992,6 +992,7 @@ class TorrentManager(component.Component):
|
||||||
torrent.forcing_recheck = False
|
torrent.forcing_recheck = False
|
||||||
if torrent.forcing_recheck_paused:
|
if torrent.forcing_recheck_paused:
|
||||||
torrent.handle.pause()
|
torrent.handle.pause()
|
||||||
|
torrent.set_trackers(torrent.trackers, reannounce=False)
|
||||||
|
|
||||||
# Set the torrent state
|
# Set the torrent state
|
||||||
torrent.update_state()
|
torrent.update_state()
|
||||||
|
|
Loading…
Reference in New Issue