Update the use of add_torrent()

This commit is contained in:
Andrew Resch 2008-05-01 05:38:25 +00:00
parent df459e7eaa
commit 9313975ba5
1 changed files with 26 additions and 12 deletions

View File

@ -257,16 +257,23 @@ class TorrentManager(component.Component):
# 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.
component.pause("AlertManager") component.pause("AlertManager")
# Create the torrent parameters struct for the torrent's options
t_params = {}
t_params["ti"] = lt.torrent_info(filedump)
t_params["save_path"] = str(options["download_location"])
t_params["resume_data"] = fastresume
t_params["storage_mode"] = storage_mode
t_params["paused"] = True
t_params["auto_managed"] = False
t_params["duplicate_is_error"] = True
try: try:
handle = self.session.add_torrent( handle = self.session.add_torrent(t_params)
lt.torrent_info(filedump),
str(options["download_location"]),
resume_data=fastresume,
storage_mode=storage_mode,
paused=True)
except RuntimeError, e: except RuntimeError, e:
log.warning("Error adding torrent: %s", e) log.warning("Error adding torrent: %s", e)
if not handle or not handle.is_valid(): if not handle or not handle.is_valid():
log.debug("torrent handle is invalid!") log.debug("torrent handle is invalid!")
# The torrent was not added to the session # The torrent was not added to the session
@ -443,12 +450,19 @@ class TorrentManager(component.Component):
storage_mode = lt.storage_mode_t(1) storage_mode = lt.storage_mode_t(1)
# Add the torrent to the lt session # Add the torrent to the lt session
# Create the torrent parameters struct for the torrent's options
t_params = lt.add_torrent_params()
t_params.ti = lt.torrent_info(torrent_info)
t_params.save_path = str(torrent.save_path)
t_params.storage_mode = storage_mode
t_params.paused = paused
t_params.auto_managed = False
t_params.duplicate_is_error = True
try: try:
torrent.handle = self.session.add_torrent( handle = self.session.add_torrent(t_params)
lt.torrent_info(torrent_info),
str(torrent.save_path),
storage_mode=storage_mode,
paused=paused)
except RuntimeError, e: except RuntimeError, e:
log.warning("Error adding torrent: %s", e) log.warning("Error adding torrent: %s", e)