Fix an issue with daemon speedups with file priorities for magnets

Ensure prioritize_first_last gets set properly for magnets
This commit is contained in:
Chase Sterling 2013-02-10 23:57:46 -05:00
parent 8c106ce8c4
commit c11262082e
2 changed files with 11 additions and 4 deletions

View File

@ -230,10 +230,20 @@ class Torrent(object):
if log.isEnabledFor(logging.DEBUG):
log.debug("Torrent object created.")
def on_metadata_received(self):
self.handle_has_metadata = True
self.torrent_info = self.handle.get_torrent_info()
if self.options["prioritize_first_last_pieces"]:
self.set_prioritize_first_last(True)
self.write_torrentfile()
def has_metadata(self):
if self.handle_has_metadata:
return self.handle_has_metadata
self.handle_has_metadata = self.handle.has_metadata()
if self.handle_has_metadata:
# We just got the metadata
self.on_metadata_received()
return self.handle_has_metadata
## Options methods ##
@ -731,9 +741,6 @@ class Torrent(object):
#print " update_status"
self.status = status
if self.torrent_info is None and self.has_metadata():
self.torrent_info = self.handle.get_torrent_info()
def _create_status_funcs(self):
#if you add a key here->add it to core.py STATUS_KEYS too.
self.status_funcs = {

View File

@ -1104,7 +1104,7 @@ class TorrentManager(component.Component):
torrent = self.torrents[str(alert.handle.info_hash())]
except:
return
torrent.write_torrentfile()
torrent.on_metadata_received()
def on_alert_file_error(self, alert):
log.debug("on_alert_file_error: %s", decode_string(alert.message()))