From c259aea06a571674b2829794ec168ec9247dae9a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 15 Oct 2007 09:01:59 +0000 Subject: [PATCH] Fix adding/removing torrents with current libtorrent. --- deluge/core/torrentmanager.py | 10 ++++++++-- libtorrent/bindings/python/src/session.cpp | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 3cea9beae..222ddeebc 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -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 diff --git a/libtorrent/bindings/python/src/session.cpp b/libtorrent/bindings/python/src/session.cpp index 7332da2ea..05ec2a497 100755 --- a/libtorrent/bindings/python/src/session.cpp +++ b/libtorrent/bindings/python/src/session.cpp @@ -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 )