Fix adding/removing torrents with current libtorrent.

This commit is contained in:
Andrew Resch 2007-10-15 09:01:59 +00:00
parent b02b71e978
commit c259aea06a
2 changed files with 10 additions and 4 deletions

View File

@ -171,13 +171,19 @@ class TorrentManager:
# Make sure we are adding it with the correct allocation method.
if compact is None:
compact = self.config["compact_allocation"]
# Set the right storage_mode
if compact:
storage_mode = lt.storage_mode_t(1)
else:
storage_mode = lt.storage_mode_t(2)
try:
handle = self.session.add_torrent(
lt.torrent_info(torrent_filedump),
str(save_path),
resume_data=fastresume,
compact_mode=compact,
storage_mode=storage_mode,
paused=paused)
except RuntimeError:
log.warning("Error adding torrent")
@ -228,7 +234,7 @@ class TorrentManager:
"""Remove a torrent from the manager"""
try:
# Remove from libtorrent session
self.session.remove_torrent(self.torrents[torrent_id].handle)
self.session.remove_torrent(self.torrents[torrent_id].handle, 0)
except RuntimeError, KeyError:
log.warning("Error removing torrent")
return False

View File

@ -185,8 +185,8 @@ void bind_session()
.def(
"add_torrent", &add_torrent
, (
arg("resume_data") = entry(), arg("compact_mode") = true
, arg("paused") = false
arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse,
arg("paused") = false
)
, session_add_torrent_doc
)