fix handling of invalid torrents
This commit is contained in:
parent
ea7fdc3bc1
commit
c21f650c45
|
@ -358,8 +358,13 @@ class Manager:
|
|||
|
||||
# Dump torrent info without adding
|
||||
def dump_torrent_file_info(self, torrent):
|
||||
return deluge_core.dump_file_info(torrent)
|
||||
|
||||
try:
|
||||
ret = deluge_core.dump_file_info(torrent)
|
||||
except SystemError:
|
||||
print "invalid file"
|
||||
else:
|
||||
return ret
|
||||
|
||||
# Dump trackers from torrent file
|
||||
def dump_trackers(self, torrent):
|
||||
return deluge_core.dump_trackers(torrent)
|
||||
|
|
|
@ -212,8 +212,7 @@ torrent_info internal_get_torrent_info(std::string const& torrent_name)
|
|||
{
|
||||
std::ifstream in(torrent_name.c_str(), std::ios_base::binary);
|
||||
in.unsetf(std::ios_base::skipws);
|
||||
entry e;
|
||||
e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
||||
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
||||
|
||||
torrent_info t(e);
|
||||
|
||||
|
@ -691,27 +690,32 @@ static PyObject *torrent_dump_file_info(PyObject *self, PyObject *args)
|
|||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return NULL;
|
||||
|
||||
torrent_info t = internal_get_torrent_info(name);
|
||||
try{
|
||||
torrent_info t = internal_get_torrent_info(name);
|
||||
|
||||
PyObject *file_info;
|
||||
long file_index = 0;
|
||||
PyObject *ret = PyTuple_New(t.num_files());
|
||||
|
||||
for(torrent_info::file_iterator i = t.begin_files(); i != t.end_files(); ++i)
|
||||
{
|
||||
file_entry const &currFile = (*i);
|
||||
|
||||
file_info = Py_BuildValue(
|
||||
"{s:s,s:L}",
|
||||
"path", currFile.path.string().c_str(),
|
||||
"size", currFile.size
|
||||
);
|
||||
|
||||
PyTuple_SetItem(ret, file_index, file_info);
|
||||
file_index++;
|
||||
};
|
||||
|
||||
return ret;
|
||||
PyObject *file_info;
|
||||
long file_index = 0;
|
||||
PyObject *ret = PyTuple_New(t.num_files());
|
||||
|
||||
for(torrent_info::file_iterator i = t.begin_files(); i != t.end_files(); ++i)
|
||||
{
|
||||
file_entry const &currFile = (*i);
|
||||
|
||||
file_info = Py_BuildValue(
|
||||
"{s:s,s:L}",
|
||||
"path", currFile.path.string().c_str(),
|
||||
"size", currFile.size
|
||||
);
|
||||
|
||||
PyTuple_SetItem(ret, file_index, file_info);
|
||||
file_index++;
|
||||
};
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch(invalid_encoding&){
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *torrent_dump_trackers(PyObject *self, PyObject *args)
|
||||
|
|
|
@ -1454,6 +1454,8 @@ torrent error."))
|
|||
dialogs.show_popup_warning(self.window, _("There is not enough free\
|
||||
disk space to complete your download.") + "\n" + _("Space Needed:") + " " + \
|
||||
nice_need + "\n" + _("Available Space:") + " " + nice_free)
|
||||
except core.InvalidEncodingError, e:
|
||||
print "invalid encoding\n"
|
||||
else:
|
||||
self.torrent_model_append(unique_id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue