Added per torrent max connections and max upload slots preferences.
This commit is contained in:
parent
b9a5b1c7a3
commit
758b5d8851
File diff suppressed because it is too large
Load Diff
|
@ -33,11 +33,13 @@ LOCATION_KEYS = [
|
||||||
"auto_end_seeding",
|
"auto_end_seeding",
|
||||||
"auto_seed_ratio",
|
"auto_seed_ratio",
|
||||||
"end_seed_ratio",
|
"end_seed_ratio",
|
||||||
"max_connections",
|
"max_connections_global",
|
||||||
|
"max_connections_per_torrent",
|
||||||
"max_download_rate",
|
"max_download_rate",
|
||||||
"max_download_rate_bps",
|
"max_download_rate_bps",
|
||||||
"max_number_downloads",
|
"max_number_downloads",
|
||||||
"max_number_uploads",
|
"max_upload_slots_global",
|
||||||
|
"max_upload_slots_per_torrent",
|
||||||
"max_upload_rate",
|
"max_upload_rate",
|
||||||
"max_upload_rate_bps",
|
"max_upload_rate_bps",
|
||||||
"max_uploads",
|
"max_uploads",
|
||||||
|
|
23
src/core.py
23
src/core.py
|
@ -69,9 +69,9 @@ DHT_FILENAME = "dht.state"
|
||||||
|
|
||||||
PREF_FUNCTIONS = {
|
PREF_FUNCTIONS = {
|
||||||
"listen_on" : deluge_core.set_listen_on,
|
"listen_on" : deluge_core.set_listen_on,
|
||||||
"max_connections" : deluge_core.set_max_connections,
|
"max_connections_global" : deluge_core.set_max_connections_global,
|
||||||
"max_active_torrents" : None, # no need for a function, applied constantly
|
"max_active_torrents" : None, # no need for a function, applied constantly
|
||||||
"max_number_uploads" : deluge_core.set_max_uploads,
|
"max_upload_slots_global" : deluge_core.set_max_upload_slots_global,
|
||||||
"auto_seed_ratio" : None, # no need for a function, applied constantly
|
"auto_seed_ratio" : None, # no need for a function, applied constantly
|
||||||
"max_download_speed_bps" : deluge_core.set_download_rate_limit,
|
"max_download_speed_bps" : deluge_core.set_download_rate_limit,
|
||||||
"max_upload_speed_bps" : deluge_core.set_upload_rate_limit,
|
"max_upload_speed_bps" : deluge_core.set_upload_rate_limit,
|
||||||
|
@ -903,10 +903,14 @@ class Manager:
|
||||||
else:
|
else:
|
||||||
PREF_FUNCTIONS[pref](self.get_pref(pref))
|
PREF_FUNCTIONS[pref](self.get_pref(pref))
|
||||||
|
|
||||||
# We need to reapply priorities to files after preferences were
|
# We need to reapply priorities to files and per torrent options after
|
||||||
# changed
|
# preferences were changed.
|
||||||
for unique_ID in self.unique_IDs:
|
for unique_ID in self.unique_IDs:
|
||||||
self.prioritize_files(unique_ID, self.get_priorities(unique_ID))
|
self.prioritize_files(unique_ID, self.get_priorities(unique_ID))
|
||||||
|
self.set_max_connections_per_torrent(unique_ID,
|
||||||
|
self.get_pref("max_connections_per_torrent"))
|
||||||
|
self.set_max_upload_slots_per_torrent(unique_ID,
|
||||||
|
self.get_pref("max_upload_slots_per_torrent"))
|
||||||
|
|
||||||
def set_DHT(self, start=False):
|
def set_DHT(self, start=False):
|
||||||
if start == True and self.dht_running != True:
|
if start == True and self.dht_running != True:
|
||||||
|
@ -957,12 +961,17 @@ class Manager:
|
||||||
def replace_trackers(self, unique_ID, trackers):
|
def replace_trackers(self, unique_ID, trackers):
|
||||||
return deluge_core.replace_trackers(unique_ID, trackers)
|
return deluge_core.replace_trackers(unique_ID, trackers)
|
||||||
|
|
||||||
def set_flp(self, unique_ID, num):
|
|
||||||
return deluge_core.set_flp(unique_ID, int(num))
|
|
||||||
|
|
||||||
def set_priv(self, unique_ID, on_off):
|
def set_priv(self, unique_ID, on_off):
|
||||||
return deluge_core.set_priv(unique_ID, on_off)
|
return deluge_core.set_priv(unique_ID, on_off)
|
||||||
|
|
||||||
|
def set_max_connections_per_torrent(self, unique_ID, max_connections):
|
||||||
|
return deluge_core.set_max_connections_per_torrent(unique_ID,
|
||||||
|
max_connections)
|
||||||
|
|
||||||
|
def set_max_upload_slots_per_torrent(self, unique_ID, max_upload_slots):
|
||||||
|
return deluge_core.set_max_upload_slots_per_torrent(unique_ID,
|
||||||
|
max_upload_slots)
|
||||||
|
|
||||||
def set_per_upload_rate_limit(self, unique_ID, speed):
|
def set_per_upload_rate_limit(self, unique_ID, speed):
|
||||||
if speed != -1:
|
if speed != -1:
|
||||||
speed = speed * 1024
|
speed = speed * 1024
|
||||||
|
|
|
@ -551,7 +551,7 @@ static PyObject *torrent_listening_port(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *torrent_set_max_uploads(PyObject *self, PyObject *args)
|
static PyObject *torrent_set_max_upload_slots_global(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
python_long max_up;
|
python_long max_up;
|
||||||
if (!PyArg_ParseTuple(args, "i", &max_up))
|
if (!PyArg_ParseTuple(args, "i", &max_up))
|
||||||
|
@ -563,7 +563,7 @@ static PyObject *torrent_set_max_uploads(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *torrent_set_max_connections(PyObject *self, PyObject *args)
|
static PyObject *torrent_set_max_connections_global(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
python_long max_conn;
|
python_long max_conn;
|
||||||
if (!PyArg_ParseTuple(args, "i", &max_conn))
|
if (!PyArg_ParseTuple(args, "i", &max_conn))
|
||||||
|
@ -1720,28 +1720,6 @@ static PyObject *torrent_replace_trackers(PyObject *self, PyObject *args)
|
||||||
h.force_reannounce();
|
h.force_reannounce();
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
static PyObject *torrent_set_flp(PyObject *self, PyObject *args)
|
|
||||||
{
|
|
||||||
python_long unique_ID;
|
|
||||||
int num;
|
|
||||||
if (!PyArg_ParseTuple(args, "ii", &unique_ID, &num))
|
|
||||||
return NULL;
|
|
||||||
long index = get_index_from_unique_ID(unique_ID);
|
|
||||||
if (PyErr_Occurred())
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
torrent_t &t = M_torrents->at(index);
|
|
||||||
torrent_status s = t.handle.status();
|
|
||||||
const torrent_info &i = t.handle.get_torrent_info();
|
|
||||||
|
|
||||||
int npieces = i.num_pieces() - 1;
|
|
||||||
|
|
||||||
t.handle.piece_priority(0, num);
|
|
||||||
t.handle.piece_priority(npieces, num);
|
|
||||||
|
|
||||||
return Py_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PyObject *torrent_prioritize_files(PyObject *self, PyObject *args)
|
static PyObject *torrent_prioritize_files(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
python_long unique_ID;
|
python_long unique_ID;
|
||||||
|
@ -1883,6 +1861,38 @@ static PyObject *torrent_set_priv(PyObject *self, PyObject *args)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *torrent_set_max_connections_per_torrent(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
python_long unique_ID, max_connections;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "ii", &unique_ID, &max_connections))
|
||||||
|
return NULL;
|
||||||
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
torrent_t &t = M_torrents->at(index);
|
||||||
|
t.handle.set_max_connections(max_connections);
|
||||||
|
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *torrent_set_max_upload_slots_per_torrent(PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
python_long unique_ID, max_upload_slots;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "ii", &unique_ID, &max_upload_slots))
|
||||||
|
return NULL;
|
||||||
|
long index = get_index_from_unique_ID(unique_ID);
|
||||||
|
if (PyErr_Occurred())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
torrent_t &t = M_torrents->at(index);
|
||||||
|
t.handle.set_max_uploads(max_upload_slots);
|
||||||
|
|
||||||
|
return Py_None;
|
||||||
|
}
|
||||||
|
|
||||||
//====================
|
//====================
|
||||||
// Python Module data
|
// Python Module data
|
||||||
//====================
|
//====================
|
||||||
|
@ -1902,8 +1912,10 @@ static PyMethodDef deluge_core_methods[] =
|
||||||
{"set_listen_on", torrent_set_listen_on, METH_VARARGS, "."},
|
{"set_listen_on", torrent_set_listen_on, METH_VARARGS, "."},
|
||||||
{"is_listening", torrent_is_listening, METH_VARARGS, "."},
|
{"is_listening", torrent_is_listening, METH_VARARGS, "."},
|
||||||
{"listening_port", torrent_listening_port, METH_VARARGS, "."},
|
{"listening_port", torrent_listening_port, METH_VARARGS, "."},
|
||||||
{"set_max_uploads", torrent_set_max_uploads, METH_VARARGS, "."},
|
{"set_max_upload_slots_global", torrent_set_max_upload_slots_global, METH_VARARGS, "."},
|
||||||
{"set_max_connections", torrent_set_max_connections, METH_VARARGS, "."},
|
{"set_max_upload_slots_per_torrent",torrent_set_max_upload_slots_per_torrent, METH_VARARGS, "."},
|
||||||
|
{"set_max_connections_global", torrent_set_max_connections_global, METH_VARARGS, "."},
|
||||||
|
{"set_max_connections_per_torrent", torrent_set_max_connections_per_torrent, METH_VARARGS, "."},
|
||||||
{"add_torrent", torrent_add_torrent, METH_VARARGS, "."},
|
{"add_torrent", torrent_add_torrent, METH_VARARGS, "."},
|
||||||
{"move_storage", torrent_move_storage, METH_VARARGS, "."},
|
{"move_storage", torrent_move_storage, METH_VARARGS, "."},
|
||||||
{"remove_torrent", torrent_remove_torrent, METH_VARARGS, "."},
|
{"remove_torrent", torrent_remove_torrent, METH_VARARGS, "."},
|
||||||
|
@ -1933,7 +1945,6 @@ static PyMethodDef deluge_core_methods[] =
|
||||||
{"get_trackers", torrent_get_trackers, METH_VARARGS, "."},
|
{"get_trackers", torrent_get_trackers, METH_VARARGS, "."},
|
||||||
{"dump_trackers", torrent_dump_trackers, METH_VARARGS, "."},
|
{"dump_trackers", torrent_dump_trackers, METH_VARARGS, "."},
|
||||||
{"replace_trackers", torrent_replace_trackers, METH_VARARGS, "."},
|
{"replace_trackers", torrent_replace_trackers, METH_VARARGS, "."},
|
||||||
{"set_flp", torrent_set_flp, METH_VARARGS, "."},
|
|
||||||
{"prioritize_files", torrent_prioritize_files, METH_VARARGS, "."},
|
{"prioritize_files", torrent_prioritize_files, METH_VARARGS, "."},
|
||||||
{"prioritize_first_last_pieces", torrent_prioritize_first_last_pieces, METH_VARARGS, "."},
|
{"prioritize_first_last_pieces", torrent_prioritize_first_last_pieces, METH_VARARGS, "."},
|
||||||
{"set_priv", torrent_set_priv, METH_VARARGS, "."},
|
{"set_priv", torrent_set_priv, METH_VARARGS, "."},
|
||||||
|
|
|
@ -95,9 +95,11 @@ class PreferencesDlg:
|
||||||
self.glade.get_widget("spin_port_min").set_value(self.preferences.get("listen_on")[0])
|
self.glade.get_widget("spin_port_min").set_value(self.preferences.get("listen_on")[0])
|
||||||
self.glade.get_widget("spin_port_max").set_value(self.preferences.get("listen_on")[1])
|
self.glade.get_widget("spin_port_max").set_value(self.preferences.get("listen_on")[1])
|
||||||
self.glade.get_widget("spin_max_upload").set_value(self.preferences.get("max_upload_speed"))
|
self.glade.get_widget("spin_max_upload").set_value(self.preferences.get("max_upload_speed"))
|
||||||
self.glade.get_widget("spin_num_upload").set_value(float(self.preferences.get("max_number_uploads")))
|
self.glade.get_widget("spin_max_upload_slots_global").set_value(float(self.preferences.get("max_upload_slots_global")))
|
||||||
|
self.glade.get_widget("spin_max_upload_slots_per_torrent").set_value(float(self.preferences.get("max_upload_slots_per_torrent")))
|
||||||
self.glade.get_widget("spin_max_download").set_value(self.preferences.get("max_download_speed"))
|
self.glade.get_widget("spin_max_download").set_value(self.preferences.get("max_download_speed"))
|
||||||
self.glade.get_widget("spin_max_connections").set_value(self.preferences.get("max_connections"))
|
self.glade.get_widget("spin_max_connections_global").set_value(self.preferences.get("max_connections_global"))
|
||||||
|
self.glade.get_widget("spin_max_connections_per_torrent").set_value(self.preferences.get("max_connections_per_torrent"))
|
||||||
self.glade.get_widget("spin_peer_proxy_port").set_value(self.preferences.get("peer_proxy_port"))
|
self.glade.get_widget("spin_peer_proxy_port").set_value(self.preferences.get("peer_proxy_port"))
|
||||||
self.glade.get_widget("spin_tracker_proxy_port").set_value(self.preferences.get("tracker_proxy_port"))
|
self.glade.get_widget("spin_tracker_proxy_port").set_value(self.preferences.get("tracker_proxy_port"))
|
||||||
self.glade.get_widget("spin_dht_proxy_port").set_value(self.preferences.get("dht_proxy_port"))
|
self.glade.get_widget("spin_dht_proxy_port").set_value(self.preferences.get("dht_proxy_port"))
|
||||||
|
@ -199,13 +201,15 @@ class PreferencesDlg:
|
||||||
self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active())
|
self.preferences.set("use_compact_storage", self.glade.get_widget("chk_compact").get_active())
|
||||||
self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()])
|
self.preferences.set("listen_on", [self.glade.get_widget("spin_port_min").get_value(), self.glade.get_widget("spin_port_max").get_value()])
|
||||||
self.preferences.set("max_upload_speed", self.glade.get_widget("spin_max_upload").get_value())
|
self.preferences.set("max_upload_speed", self.glade.get_widget("spin_max_upload").get_value())
|
||||||
self.preferences.set("max_number_uploads", int(self.glade.get_widget("spin_num_upload").get_value()))
|
self.preferences.set("max_upload_slots_global", int(self.glade.get_widget("spin_max_upload_slots_global").get_value()))
|
||||||
|
self.preferences.set("max_upload_slots_per_torrent", int(self.glade.get_widget("spin_max_upload_slots_per_torrent").get_value()))
|
||||||
self.preferences.set("max_download_speed", self.glade.get_widget("spin_max_download").get_value())
|
self.preferences.set("max_download_speed", self.glade.get_widget("spin_max_download").get_value())
|
||||||
self.preferences.set("peer_proxy_port", self.glade.get_widget("spin_peer_proxy_port").get_value())
|
self.preferences.set("peer_proxy_port", self.glade.get_widget("spin_peer_proxy_port").get_value())
|
||||||
self.preferences.set("dht_proxy_port", self.glade.get_widget("spin_dht_proxy_port").get_value())
|
self.preferences.set("dht_proxy_port", self.glade.get_widget("spin_dht_proxy_port").get_value())
|
||||||
self.preferences.set("web_proxy_port", self.glade.get_widget("spin_web_proxy_port").get_value())
|
self.preferences.set("web_proxy_port", self.glade.get_widget("spin_web_proxy_port").get_value())
|
||||||
self.preferences.set("tracker_proxy_port", self.glade.get_widget("spin_tracker_proxy_port").get_value())
|
self.preferences.set("tracker_proxy_port", self.glade.get_widget("spin_tracker_proxy_port").get_value())
|
||||||
self.preferences.set("max_connections", int(self.glade.get_widget("spin_max_connections").get_value()))
|
self.preferences.set("max_connections_global", int(self.glade.get_widget("spin_max_connections_global").get_value()))
|
||||||
|
self.preferences.set("max_connections_per_torrent", int(self.glade.get_widget("spin_max_connections_per_torrent").get_value()))
|
||||||
self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value()))
|
self.preferences.set("max_active_torrents", int(self.glade.get_widget("spin_torrents").get_value()))
|
||||||
self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active())
|
self.preferences.set("queue_seeds_to_bottom", self.glade.get_widget("chk_seedbottom").get_active())
|
||||||
self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active())
|
self.preferences.set("enable_dht", self.glade.get_widget("chk_dht").get_active())
|
||||||
|
|
|
@ -943,10 +943,10 @@ class DelugeGTK:
|
||||||
def update_statusbar_and_tray(self):
|
def update_statusbar_and_tray(self):
|
||||||
core_state = self.manager.get_state()
|
core_state = self.manager.get_state()
|
||||||
connections = core_state['num_peers']
|
connections = core_state['num_peers']
|
||||||
if self.config.get("max_connections") < 0 :
|
if self.config.get("max_connections_global") < 0 :
|
||||||
max_connections = _("Unlimited")
|
max_connections = _("Unlimited")
|
||||||
else:
|
else:
|
||||||
max_connections = int(self.config.get("max_connections"))
|
max_connections = int(self.config.get("max_connections_global"))
|
||||||
dlspeed = common.fspeed(core_state['download_rate'])
|
dlspeed = common.fspeed(core_state['download_rate'])
|
||||||
ulspeed = common.fspeed(core_state['upload_rate'])
|
ulspeed = common.fspeed(core_state['upload_rate'])
|
||||||
dltotal = common.fsize(core_state['total_downloaded'])
|
dltotal = common.fsize(core_state['total_downloaded'])
|
||||||
|
|
|
@ -62,10 +62,12 @@ DEFAULT_PREFS = {
|
||||||
"listen_on" : [6881,6889],
|
"listen_on" : [6881,6889],
|
||||||
"lock_tray" : False,
|
"lock_tray" : False,
|
||||||
"max_active_torrents" : 8,
|
"max_active_torrents" : 8,
|
||||||
"max_connections" : 200,
|
"max_connections_global" : 200,
|
||||||
|
"max_connections_per_torrent" : -1,
|
||||||
"max_download_speed" : -1,
|
"max_download_speed" : -1,
|
||||||
"max_download_speed_bps": -1,
|
"max_download_speed_bps": -1,
|
||||||
"max_number_uploads" : 10,
|
"max_upload_slots_global" : 15,
|
||||||
|
"max_upload_slots_per_torrent" : -1,
|
||||||
"max_upload_speed" : -1,
|
"max_upload_speed" : -1,
|
||||||
"max_upload_speed_bps" : -1,
|
"max_upload_speed_bps" : -1,
|
||||||
"pref_rc4" : True,
|
"pref_rc4" : True,
|
||||||
|
|
Loading…
Reference in New Issue