diff --git a/deluge/core/core.py b/deluge/core/core.py index 9d8cafc0b..cfad4e562 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -497,7 +497,7 @@ class Core( def export_force_recheck(self, torrent_ids): """Forces a data recheck on torrent_ids""" for torrent_id in torrent_ids: - gobject.idle_add(self.torrents.force_recheck, torrent_id) + self.torrents[torrent_id].force_recheck() def export_set_torrent_trackers(self, torrent_id, trackers): """Sets a torrents tracker list. trackers will be [{"url", "tier"}]""" diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 484fe61fb..856422cff 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -557,3 +557,13 @@ class Torrent: return False return True + + def force_recheck(self): + """Forces a recheck of the torrents pieces""" + try: + self.handle.force_recheck() + except Exception, e: + log.debug("Unable to force recheck: %s", e) + return False + return True + diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 1411f077c..070ffdccf 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -407,70 +407,6 @@ class TorrentManager(component.Component): log.warning("Unable to resume torrent %s", key) return torrent_was_resumed - - def force_recheck(self, torrent_id): - """Forces a re-check of the torrent's data""" - log.debug("force recheck is broken for the time being") - return - log.debug("Doing a forced recheck on %s", torrent_id) - torrent = self.torrents[torrent_id] - paused = self.torrents[torrent_id].handle.is_paused() - torrent_info = torrent.handle.get_torrent_info() - - # We need to pause the AlertManager momentarily to prevent alerts - # for this torrent being generated before a Torrent object is created. - component.pause("AlertManager") - - # We start by removing it from the lt session - try: - self.session.remove_torrent(torrent.handle, 0) - except (RuntimeError, KeyError), e: - log.warning("Error removing torrent: %s", e) - return False - - # Remove the fastresume file if there - #torrent.delete_fastresume() - - # Load the torrent info from file if needed - if torrent_info == None: - torrent_info = self.load_torrent(torrent.torrent_id) - - # Next we re-add the torrent - - # Set the right storage_mode - if torrent.compact: - storage_mode = lt.storage_mode_t(2) - else: - storage_mode = lt.storage_mode_t(1) - - # Add the torrent to the lt session - - # Create the torrent parameters struct for the torrent's options - t_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 - t_params["resume_data"] = None - - try: - torrent.handle = self.session.add_torrent(t_params) - except RuntimeError, e: - log.warning("Error adding torrent: %s", e) - - if not torrent.handle or not torrent.handle.is_valid(): - # The torrent was not added to the session - return False - - component.resume("AlertManager") - # Set all the per-torrent options - torrent.apply_options() - - # Set the state to Checking - torrent.set_state("Checking") def load_state(self): """Load the state of the TorrentManager from the torrents.state file""" diff --git a/libtorrent/bindings/python/src/torrent_handle.cpp b/libtorrent/bindings/python/src/torrent_handle.cpp index 5284ccfab..9980e940f 100755 --- a/libtorrent/bindings/python/src/torrent_handle.cpp +++ b/libtorrent/bindings/python/src/torrent_handle.cpp @@ -268,9 +268,9 @@ void bind_torrent_handle() .def("pause", _(&torrent_handle::pause)) .def("resume", _(&torrent_handle::resume)) - .def_readonly("is_auto_managed", _(&torrent_handle::is_auto_managed)) + .def("is_auto_managed", _(&torrent_handle::is_auto_managed)) .def("auto_managed", _(&torrent_handle::auto_managed)) - .def_readonly("queue_position", _(&torrent_handle::queue_position)) + .def("queue_position", _(&torrent_handle::queue_position)) .def("queue_position_up", _(&torrent_handle::queue_position_up)) .def("queue_position_down", _(&torrent_handle::queue_position_down)) .def("queue_position_top", _(&torrent_handle::queue_position_top)) @@ -312,6 +312,7 @@ void bind_torrent_handle() .def("set_tracker_login", _(&torrent_handle::set_tracker_login)) .def("move_storage", _(&torrent_handle::move_storage)) .def("info_hash", _(&torrent_handle::info_hash)) + .def("force_recheck", _(&torrent_handle::force_recheck)) ; }