fix handling of invalid torrents

This commit is contained in:
Marcos Pinto 2007-12-29 03:16:30 +00:00
parent ea7fdc3bc1
commit c21f650c45
3 changed files with 35 additions and 24 deletions

View File

@ -358,7 +358,12 @@ 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):

View File

@ -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,6 +690,7 @@ static PyObject *torrent_dump_file_info(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &name))
return NULL;
try{
torrent_info t = internal_get_torrent_info(name);
PyObject *file_info;
@ -712,6 +712,10 @@ static PyObject *torrent_dump_file_info(PyObject *self, PyObject *args)
};
return ret;
}
catch(invalid_encoding&){
return NULL;
}
}
static PyObject *torrent_dump_trackers(PyObject *self, PyObject *args)

View File

@ -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)