mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
fix saving fast resume on checking torrents
This commit is contained in:
parent
379eac85c4
commit
263387c6c9
1 changed files with 20 additions and 25 deletions
|
@ -469,35 +469,30 @@ static PyObject *torrent_save_fastresume(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "is", &unique_ID, &torrent_name))
|
if (!PyArg_ParseTuple(args, "is", &unique_ID, &torrent_name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
long index = get_index_from_unique_ID(unique_ID);
|
try{
|
||||||
if (PyErr_Occurred())
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
return NULL;
|
if (PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
torrent_handle& h = M_torrents->at(index).handle;
|
torrent_handle& h = M_torrents->at(index).handle;
|
||||||
// For valid torrents, save fastresume data
|
// For valid torrents, save fastresume data
|
||||||
if (h.is_valid() && h.has_metadata())
|
if (h.is_valid() && h.has_metadata())
|
||||||
{
|
{
|
||||||
h.pause();
|
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<char>(out), data);
|
||||||
|
|
||||||
entry data = h.write_resume_data();
|
}
|
||||||
|
}
|
||||||
std::stringstream s;
|
catch(...){
|
||||||
s << torrent_name << ".fastresume";
|
printf("Fast resume saving failed\n");
|
||||||
|
}
|
||||||
boost::filesystem::ofstream out(s.str(), std::ios_base::binary);
|
Py_INCREF(Py_None); return Py_None;
|
||||||
|
|
||||||
out.unsetf(std::ios_base::skipws);
|
|
||||||
|
|
||||||
bencode(std::ostream_iterator<char>(out), data);
|
|
||||||
|
|
||||||
h.resume();
|
|
||||||
|
|
||||||
Py_INCREF(Py_None); return Py_None;
|
|
||||||
} else
|
|
||||||
RAISE_PTR(DelugeError, "Invalid handle or no metadata for fastresume.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args)
|
static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
python_long arg;
|
python_long arg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue