raise gui warning on move_storage failure

This commit is contained in:
Marcos Pinto 2007-07-12 19:38:47 +00:00
parent e09d489077
commit 4c03881aba
4 changed files with 18 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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