mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-12 19:28:42 +00:00
fix handling of invalid torrents
This commit is contained in:
parent
ea7fdc3bc1
commit
c21f650c45
3 changed files with 35 additions and 24 deletions
|
@ -358,7 +358,12 @@ class Manager:
|
||||||
|
|
||||||
# Dump torrent info without adding
|
# Dump torrent info without adding
|
||||||
def dump_torrent_file_info(self, torrent):
|
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
|
# Dump trackers from torrent file
|
||||||
def dump_trackers(self, torrent):
|
def dump_trackers(self, 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);
|
std::ifstream in(torrent_name.c_str(), std::ios_base::binary);
|
||||||
in.unsetf(std::ios_base::skipws);
|
in.unsetf(std::ios_base::skipws);
|
||||||
entry e;
|
entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
||||||
e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
|
|
||||||
|
|
||||||
torrent_info t(e);
|
torrent_info t(e);
|
||||||
|
|
||||||
|
@ -691,27 +690,32 @@ static PyObject *torrent_dump_file_info(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "s", &name))
|
if (!PyArg_ParseTuple(args, "s", &name))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
torrent_info t = internal_get_torrent_info(name);
|
try{
|
||||||
|
torrent_info t = internal_get_torrent_info(name);
|
||||||
|
|
||||||
PyObject *file_info;
|
PyObject *file_info;
|
||||||
long file_index = 0;
|
long file_index = 0;
|
||||||
PyObject *ret = PyTuple_New(t.num_files());
|
PyObject *ret = PyTuple_New(t.num_files());
|
||||||
|
|
||||||
for(torrent_info::file_iterator i = t.begin_files(); i != t.end_files(); ++i)
|
for(torrent_info::file_iterator i = t.begin_files(); i != t.end_files(); ++i)
|
||||||
{
|
{
|
||||||
file_entry const &currFile = (*i);
|
file_entry const &currFile = (*i);
|
||||||
|
|
||||||
file_info = Py_BuildValue(
|
file_info = Py_BuildValue(
|
||||||
"{s:s,s:L}",
|
"{s:s,s:L}",
|
||||||
"path", currFile.path.string().c_str(),
|
"path", currFile.path.string().c_str(),
|
||||||
"size", currFile.size
|
"size", currFile.size
|
||||||
);
|
);
|
||||||
|
|
||||||
PyTuple_SetItem(ret, file_index, file_info);
|
PyTuple_SetItem(ret, file_index, file_info);
|
||||||
file_index++;
|
file_index++;
|
||||||
};
|
};
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
catch(invalid_encoding&){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *torrent_dump_trackers(PyObject *self, PyObject *args)
|
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\
|
dialogs.show_popup_warning(self.window, _("There is not enough free\
|
||||||
disk space to complete your download.") + "\n" + _("Space Needed:") + " " + \
|
disk space to complete your download.") + "\n" + _("Space Needed:") + " " + \
|
||||||
nice_need + "\n" + _("Available Space:") + " " + nice_free)
|
nice_need + "\n" + _("Available Space:") + " " + nice_free)
|
||||||
|
except core.InvalidEncodingError, e:
|
||||||
|
print "invalid encoding\n"
|
||||||
else:
|
else:
|
||||||
self.torrent_model_append(unique_id)
|
self.torrent_model_append(unique_id)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue