move finished downloads to - eternalswd

This commit is contained in:
Marcos Pinto 2007-07-11 08:04:45 +00:00
parent c5e2b67800
commit 1e1c5ed780
4 changed files with 51 additions and 2 deletions

View File

@ -527,6 +527,8 @@ class Manager:
if event['event_type'] is self.constants['EVENT_FINISHED']:
# Queue seeding torrent to bottom if needed
if(self.get_pref('enable_move_completed')):
deluge_core.move_storage(event['unique_ID'], self.get_pref('default_finished_path'))
if self.get_pref('queue_seeds_to_bottom'):
self.queue_bottom(event['unique_ID'])
# If we are autoseeding, then we need to apply the queue

View File

@ -534,6 +534,32 @@ static PyObject *torrent_add_torrent(PyObject *self, PyObject *args)
{ RAISE_PTR(DuplicateTorrentError, "libtorrent reports this is a duplicate torrent"); }
}
static PyObject *torrent_move_storage(PyObject *self, PyObject *args)
{
const char *move_dir;
python_long unique_ID;
if (!PyArg_ParseTuple(args, "is", &unique_ID, &move_dir))
return NULL;
long index = get_index_from_unique_ID(unique_ID);
if (PyErr_Occurred())
return NULL;
boost::filesystem::path move_dir_2 (move_dir, empty_name_check);
try
{
/*libtorrent's move_storage only works within same partition
move_storage returns afterwards save_path should equal move_dir_2*/
M_torrents->at(index).handle.move_storage(move_dir_2);
//if(M_torrents->at(index).handle.save_path()!=move_dir_2)
//return NULL;
//throw error here to let user know
}
catch (boost::filesystem::filesystem_error&)
{ RAISE_PTR(FilesystemError, ""); }
Py_INCREF(Py_None); return Py_None;
}
static PyObject *torrent_remove_torrent(PyObject *self, PyObject *args)
{
@ -1407,6 +1433,7 @@ static PyMethodDef deluge_core_methods[] =
{"set_max_uploads", torrent_set_max_uploads, METH_VARARGS, "."},
{"set_max_connections", torrent_set_max_connections, METH_VARARGS, "."},
{"add_torrent", torrent_add_torrent, METH_VARARGS, "."},
{"move_storage", torrent_move_storage, METH_VARARGS, "."},
{"remove_torrent", torrent_remove_torrent, METH_VARARGS, "."},
{"get_num_torrents", torrent_get_num_torrents, METH_VARARGS, "."},
{"reannounce", torrent_reannounce, METH_VARARGS, "."},

View File

@ -45,6 +45,8 @@ class PreferencesDlg:
self.dialog.set_icon_from_file(common.get_pixmap("deluge32.png"))
self.glade.signal_autoconnect({
'on_chk_use_tray_toggled': self.tray_toggle,
'on_save_all_to' : self.toggle_move_chk,
'on_ask_save' : self.toggle_move_chk,
'on_btn_testport_clicked': self.TestPort,
})
self.parent = parent
@ -73,8 +75,14 @@ class PreferencesDlg:
self.glade.get_widget("txt_proxy_password").set_text(self.preferences.get("proxy_password"))
if(self.preferences.get("use_default_dir")):
self.glade.get_widget("radio_save_all_to").set_active(True)
self.glade.get_widget("chk_move_completed").set_sensitive(True)
self.glade.get_widget("finished_path_button").set_sensitive(True)
if(self.preferences.get("enable_move_completed")):
self.glade.get_widget("chk_move_completed").set_active(True)
else:
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("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"))
@ -121,6 +129,8 @@ class PreferencesDlg:
self.preferences.set("proxy_hostname", self.glade.get_widget("txt_proxy_hostname").get_text())
self.preferences.set("use_default_dir", self.glade.get_widget("radio_save_all_to").get_active())
self.preferences.set("default_download_path", self.glade.get_widget("download_path_button").get_filename())
self.preferences.set("enable_move_completed", self.glade.get_widget("chk_move_completed").get_active())
self.preferences.set("default_finished_path", self.glade.get_widget("finished_path_button").get_filename())
self.preferences.set("auto_end_seeding", self.glade.get_widget("chk_autoseed").get_active())
self.preferences.set("auto_seed_ratio", self.glade.get_widget("ratio_spinner").get_value())
self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active())
@ -149,6 +159,14 @@ class PreferencesDlg:
self.glade.get_widget("chk_lock_tray").set_sensitive(is_active)
self.glade.get_widget("txt_tray_passwd").set_sensitive(is_active)
def toggle_move_chk(self, widget):
if(self.glade.get_widget("radio_ask_save").get_active()):
self.glade.get_widget("chk_move_completed").set_active(False)
self.glade.get_widget("chk_move_completed").set_sensitive(False)
self.glade.get_widget("finished_path_button").set_sensitive(False)
else:
self.glade.get_widget("chk_move_completed").set_sensitive(True)
self.glade.get_widget("finished_path_button").set_sensitive(True)
class PluginDlg:
def __init__(self, parent, plugins):

View File

@ -43,6 +43,8 @@ DEFAULT_PREFS = {
"close_to_tray" : False,
"default_download_path" : "",
"default_load_path" : os.path.expanduser("~/"),
"default_finished_path" : "",
"enable_move_completed" : False,
"enable_dht" : True,
"enable_system_tray" : True,
"enabled_plugins" : "",