diff --git a/src/core.py b/src/core.py index 3ac4f5a94..4c88976b8 100644 --- a/src/core.py +++ b/src/core.py @@ -107,6 +107,9 @@ class InvalidEncodingError(DelugeError): class FilesystemError(DelugeError): pass +class SystemError(DelugeError): + pass + # Note: this may be raised both from deluge-core.cpp and deluge.py, for # different reasons, both related to duplicate torrents class DuplicateTorrentError(DelugeError): @@ -183,6 +186,7 @@ class Manager: # Pre-initialize the core's data structures deluge_core.pre_init(DelugeError, InvalidEncodingError, + SystemError, FilesystemError, DuplicateTorrentError, InvalidTorrentError) @@ -531,7 +535,8 @@ class Manager: try: deluge_core.move_storage(event['unique_ID'], self.get_pref('default_finished_path')) except SystemError: - print "You cannot move downloaded file/folder to a different partition" + raise SystemError("You cannot move torrent to a different partition. Please fix your preferences") + continue else: self.unique_IDs[event['unique_ID']].save_dir = self.get_pref('default_finished_path') if self.get_pref('queue_seeds_to_bottom'): diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 8b43b328b..4104cf117 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -127,6 +127,7 @@ torrents_t *M_torrents = NULL; static PyObject *DelugeError = NULL; static PyObject *InvalidEncodingError = NULL; static PyObject *FilesystemError = NULL; +static PyObject *SystemError = NULL; static PyObject *DuplicateTorrentError = NULL; static PyObject *InvalidTorrentError = NULL; @@ -292,8 +293,9 @@ long count_DHT_peers(entry &state) static PyObject *torrent_pre_init(PyObject *self, PyObject *args) { - if (!PyArg_ParseTuple(args, "OOOOO", &DelugeError, + if (!PyArg_ParseTuple(args, "OOOOOO", &DelugeError, &InvalidEncodingError, + &SystemError, &FilesystemError, &DuplicateTorrentError, &InvalidTorrentError)) @@ -546,16 +548,9 @@ static PyObject *torrent_move_storage(PyObject *self, PyObject *args) return NULL; boost::filesystem::path move_dir_2 (move_dir, empty_name_check); - try - { - M_torrents->at(index).handle.move_storage(move_dir_2); - if(M_torrents->at(index).handle.save_path()!=move_dir_2) - return NULL; - } - catch (boost::filesystem::filesystem_error&) - { RAISE_PTR(FilesystemError, ""); } - - Py_INCREF(Py_None); return Py_None; + M_torrents->at(index).handle.move_storage(move_dir_2); + if(M_torrents->at(index).handle.save_path()!=move_dir_2) + RAISE_PTR(SystemError, "You cannot move torrent to a different partition. Please fix your preferences"); } static PyObject *torrent_remove_torrent(PyObject *self, PyObject *args) diff --git a/src/dialogs.py b/src/dialogs.py index 2a8c5ced9..905166bd0 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -83,7 +83,7 @@ class PreferencesDlg: self.glade.get_widget("radio_ask_save").set_active(True) self.glade.get_widget("chk_move_completed").set_sensitive(False) self.glade.get_widget("finished_path_button").set_sensitive(False) - self.glade.get_widget("finished_path_button").set_filename(self.preferences.get("default_finished_path")) + self.glade.get_widget("finished_path_button").set_filename(self.preferences.get("default_finished_path")) self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path")) self.glade.get_widget("chk_compact").set_active(self.preferences.get("use_compact_storage")) self.glade.get_widget("active_port_label").set_text(str(self.parent.manager.get_state()['port'])) diff --git a/src/interface.py b/src/interface.py index 7d7208742..edbd4538d 100644 --- a/src/interface.py +++ b/src/interface.py @@ -826,7 +826,11 @@ class DelugeGTK: self.manager.apply_queue() # Handle the events - self.manager.handle_events() + try: + self.manager.handle_events() + except core.SystemError, e: + print "SystemError", e + dialogs.show_popup_warning(self.window, _("You cannot move torrent to a different partition. Please fix your preferences")) # Make sure that the interface still exists try: