persistence for speedlimiter
This commit is contained in:
parent
8e2ea90c82
commit
fae29ee8be
|
@ -75,7 +75,18 @@ class DesiredSpeed:
|
|||
self.up_speed_menuitem.set_submenu(self.up_speed_menu)
|
||||
self.interface.torrent_menu.append(self.up_speed_menuitem)
|
||||
self.up_speed_menuitem.show_all()
|
||||
|
||||
for torrent in self.core.get_queue():
|
||||
unique_ID = self.core.get_torrent_unique_id(torrent)
|
||||
if self.core.unique_IDs[unique_ID].upload_rate_limit != -1:
|
||||
self.core.set_per_upload_rate_limit(unique_ID,
|
||||
self.core.unique_IDs[unique_ID].upload_rate_limit)
|
||||
self.set_up_speeds[unique_ID] = \
|
||||
self.core.unique_IDs[unique_ID].upload_rate_limit / 1024
|
||||
if self.core.unique_IDs[unique_ID].download_rate_limit != -1:
|
||||
self.core.set_per_download_rate_limit(unique_ID,
|
||||
self.core.unique_IDs[unique_ID].download_rate_limit)
|
||||
self.set_down_speeds[unique_ID] = \
|
||||
self.core.unique_IDs[unique_ID].download_rate_limit / 1024
|
||||
|
||||
def torrent_menu_hide(self, widget):
|
||||
try:
|
||||
|
@ -139,7 +150,8 @@ class DesiredSpeed:
|
|||
|
||||
self.core.set_per_upload_rate_limit(self.unique_ID, value)
|
||||
self.set_up_speeds[self.unique_ID] = value
|
||||
|
||||
self.core.unique_IDs[self.unique_ID].upload_rate_limit = value * 1024
|
||||
|
||||
# Update the speeds list if necessary
|
||||
if value not in self.config.get("up_speeds") and value >= 1:
|
||||
self.config.get("up_speeds").insert(0, value)
|
||||
|
@ -170,6 +182,7 @@ class DesiredSpeed:
|
|||
|
||||
self.core.set_per_download_rate_limit(self.unique_ID, value)
|
||||
self.set_down_speeds[self.unique_ID] = value
|
||||
self.core.unique_IDs[self.unique_ID].download_rate_limit = value * 1024
|
||||
|
||||
# update the speeds list if necessary
|
||||
if value not in self.config.get("down_speeds") and value >= 0:
|
||||
|
|
11
src/core.py
11
src/core.py
|
@ -159,9 +159,10 @@ class torrent_info:
|
|||
self.filename = filename
|
||||
self.save_dir = save_dir
|
||||
self.compact = compact
|
||||
|
||||
self.user_paused = False # start out unpaused
|
||||
self.user_paused = False
|
||||
self.uploaded_memory = 0
|
||||
self.upload_rate_limit = 0
|
||||
self.download_rate_limit = 0
|
||||
|
||||
self.delete_me = False # set this to true, to delete it on next sync
|
||||
|
||||
|
@ -1025,5 +1026,11 @@ class Manager:
|
|||
speed = speed * 1024
|
||||
return deluge_core.set_per_download_rate_limit(unique_ID, speed)
|
||||
|
||||
def get_per_upload_rate_limit(self, unique_ID):
|
||||
return deluge_core.get_per_upload_rate_limit(unique_ID)
|
||||
|
||||
def get_per_download_rate_limit(self, unique_ID):
|
||||
return deluge_core.get_per_download_rate_limit(unique_ID)
|
||||
|
||||
def add_url_seed(self, unique_ID, address):
|
||||
return deluge_core.add_url_seed(unique_ID, address)
|
||||
|
|
|
@ -508,6 +508,20 @@ static PyObject *torrent_set_per_upload_rate_limit(PyObject *self, PyObject *arg
|
|||
Py_INCREF(Py_None); return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *torrent_get_per_upload_rate_limit(PyObject *self, PyObject *args)
|
||||
{
|
||||
python_long unique_ID;
|
||||
if (!PyArg_ParseTuple(args, "i", &unique_ID))
|
||||
return NULL;
|
||||
|
||||
long index = get_index_from_unique_ID(unique_ID);
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
|
||||
if (M_torrents->at(index).handle.is_valid())
|
||||
return Py_BuildValue("i", (python_long)M_torrents->at(index).handle.upload_limit());
|
||||
}
|
||||
|
||||
static PyObject *torrent_set_per_download_rate_limit(PyObject *self, PyObject *args)
|
||||
{
|
||||
python_long unique_ID, speed;
|
||||
|
@ -524,6 +538,20 @@ static PyObject *torrent_set_per_download_rate_limit(PyObject *self, PyObject *a
|
|||
Py_INCREF(Py_None); return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *torrent_get_per_download_rate_limit(PyObject *self, PyObject *args)
|
||||
{
|
||||
python_long unique_ID;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &unique_ID))
|
||||
return NULL;
|
||||
|
||||
long index = get_index_from_unique_ID(unique_ID);
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
if (M_torrents->at(index).handle.is_valid())
|
||||
return Py_BuildValue("i", (python_long)M_torrents->at(index).handle.download_limit());
|
||||
}
|
||||
|
||||
static PyObject *torrent_set_listen_on(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *port_vec;
|
||||
|
@ -1924,6 +1952,8 @@ static PyMethodDef deluge_core_methods[] =
|
|||
{"set_upload_rate_limit", torrent_set_upload_rate_limit, METH_VARARGS, "."},
|
||||
{"set_per_upload_rate_limit", torrent_set_per_upload_rate_limit, METH_VARARGS, "."},
|
||||
{"set_per_download_rate_limit", torrent_set_per_download_rate_limit, METH_VARARGS, "."},
|
||||
{"get_per_upload_rate_limit", torrent_get_per_upload_rate_limit, METH_VARARGS, "."},
|
||||
{"get_per_download_rate_limit", torrent_get_per_download_rate_limit, METH_VARARGS, "."},
|
||||
{"set_listen_on", torrent_set_listen_on, METH_VARARGS, "."},
|
||||
{"is_listening", torrent_is_listening, METH_VARARGS, "."},
|
||||
{"listening_port", torrent_listening_port, METH_VARARGS, "."},
|
||||
|
|
Loading…
Reference in New Issue