fix saving fast resume on checking torrents
This commit is contained in:
parent
379eac85c4
commit
263387c6c9
@ -469,6 +469,7 @@ 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;
|
||||||
|
|
||||||
|
try{
|
||||||
long index = get_index_from_unique_ID(unique_ID);
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -477,26 +478,20 @@ static PyObject *torrent_save_fastresume(PyObject *self, PyObject *args)
|
|||||||
// 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();
|
entry data = h.write_resume_data();
|
||||||
|
|
||||||
std::stringstream s;
|
std::stringstream s;
|
||||||
s << torrent_name << ".fastresume";
|
s << torrent_name << ".fastresume";
|
||||||
|
|
||||||
boost::filesystem::ofstream out(s.str(), std::ios_base::binary);
|
boost::filesystem::ofstream out(s.str(), std::ios_base::binary);
|
||||||
|
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
|
|
||||||
bencode(std::ostream_iterator<char>(out), data);
|
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.");
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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)
|
static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user