From 263387c6c94ab00e73f1b46e69d7bea05246a18b Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sat, 19 Jan 2008 04:53:36 +0000 Subject: [PATCH] fix saving fast resume on checking torrents --- src/deluge_core.cpp | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 637e93e63..6f68d79cf 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -469,35 +469,30 @@ static PyObject *torrent_save_fastresume(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is", &unique_ID, &torrent_name)) return NULL; - long index = get_index_from_unique_ID(unique_ID); - if (PyErr_Occurred()) - return NULL; + try{ + long index = get_index_from_unique_ID(unique_ID); + if (PyErr_Occurred()) + return NULL; - torrent_handle& h = M_torrents->at(index).handle; - // For valid torrents, save fastresume data - if (h.is_valid() && h.has_metadata()) - { - h.pause(); + torrent_handle& h = M_torrents->at(index).handle; + // For valid torrents, save fastresume data + if (h.is_valid() && h.has_metadata()) + { + entry data = h.write_resume_data(); + std::stringstream s; + s << torrent_name << ".fastresume"; + boost::filesystem::ofstream out(s.str(), std::ios_base::binary); + out.unsetf(std::ios_base::skipws); + bencode(std::ostream_iterator(out), data); - entry data = h.write_resume_data(); - - std::stringstream s; - s << torrent_name << ".fastresume"; - - boost::filesystem::ofstream out(s.str(), std::ios_base::binary); - - out.unsetf(std::ios_base::skipws); - - bencode(std::ostream_iterator(out), data); - - h.resume(); - - Py_INCREF(Py_None); return Py_None; - } else - RAISE_PTR(DelugeError, "Invalid handle or no metadata for fastresume."); + } + } + catch(...){ + printf("Fast resume saving failed\n"); + } + Py_INCREF(Py_None); return Py_None; } - static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args) { python_long arg;