diff --git a/src/core.py b/src/core.py index 433e574a7..2644511fc 100644 --- a/src/core.py +++ b/src/core.py @@ -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) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 382fa6f50..16a9ef83a 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -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(in), std::istream_iterator()); + entry e = bdecode(std::istream_iterator(in), std::istream_iterator()); 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) diff --git a/src/interface.py b/src/interface.py index b3f8c2494..5c265b029 100644 --- a/src/interface.py +++ b/src/interface.py @@ -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)