speedlimiter fixes

This commit is contained in:
Marcos Pinto 2007-10-07 22:38:28 +00:00
commit 1addf2541a
3 changed files with 6 additions and 10 deletions

View file

@ -56,14 +56,14 @@ class DesiredSpeed:
unique_ID = self.core.get_torrent_unique_id(torrent) unique_ID = self.core.get_torrent_unique_id(torrent)
try: try:
if self.core.unique_IDs[unique_ID].upload_rate_limit != -1: if self.core.unique_IDs[unique_ID].upload_rate_limit != -1:
value = int(self.core.unique_IDs[unique_ID].upload_rate_limit / 1024) value = int(self.core.unique_IDs[unique_ID].upload_rate_limit)
self.core.set_per_upload_rate_limit(unique_ID, value) self.core.set_per_upload_rate_limit(unique_ID, value)
self.set_up_speeds[unique_ID] = value self.set_up_speeds[unique_ID] = value
if value not in self.config.get("up_speeds") and value >= 1: if value not in self.config.get("up_speeds") and value >= 1:
self.config.get("up_speeds").insert(0, value) self.config.get("up_speeds").insert(0, value)
self.config.get("up_speeds").pop() self.config.get("up_speeds").pop()
if self.core.unique_IDs[unique_ID].download_rate_limit != -1: if self.core.unique_IDs[unique_ID].download_rate_limit != -1:
value = int(self.core.unique_IDs[unique_ID].download_rate_limit / 1024) value = int(self.core.unique_IDs[unique_ID].download_rate_limit)
self.core.set_per_download_rate_limit(unique_ID, value) self.core.set_per_download_rate_limit(unique_ID, value)
self.set_down_speeds[unique_ID] = value self.set_down_speeds[unique_ID] = value
if value not in self.config.get("down_speeds") and value >= 1: if value not in self.config.get("down_speeds") and value >= 1:
@ -157,7 +157,7 @@ class DesiredSpeed:
self.core.set_per_upload_rate_limit(self.unique_ID, value) self.core.set_per_upload_rate_limit(self.unique_ID, value)
self.set_up_speeds[self.unique_ID] = value self.set_up_speeds[self.unique_ID] = value
self.core.unique_IDs[self.unique_ID].upload_rate_limit = value * 1024 self.core.unique_IDs[self.unique_ID].upload_rate_limit = value
# Update the speeds list if necessary # Update the speeds list if necessary
if value not in self.config.get("up_speeds") and value >= 1: if value not in self.config.get("up_speeds") and value >= 1:
@ -189,7 +189,7 @@ class DesiredSpeed:
self.core.set_per_download_rate_limit(self.unique_ID, value) self.core.set_per_download_rate_limit(self.unique_ID, value)
self.set_down_speeds[self.unique_ID] = value self.set_down_speeds[self.unique_ID] = value
self.core.unique_IDs[self.unique_ID].download_rate_limit = value * 1024 self.core.unique_IDs[self.unique_ID].download_rate_limit = value
# update the speeds list if necessary # update the speeds list if necessary
if value not in self.config.get("down_speeds") and value >= 0: if value not in self.config.get("down_speeds") and value >= 0:

View file

@ -1036,13 +1036,9 @@ class Manager:
max_upload_slots) 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:
speed = speed * 1024
return deluge_core.set_per_upload_rate_limit(unique_ID, speed) return deluge_core.set_per_upload_rate_limit(unique_ID, speed)
def set_per_download_rate_limit(self, unique_ID, speed): def set_per_download_rate_limit(self, unique_ID, speed):
if speed != -1:
speed = speed * 1024
return deluge_core.set_per_download_rate_limit(unique_ID, speed) return deluge_core.set_per_download_rate_limit(unique_ID, speed)
def get_per_upload_rate_limit(self, unique_ID): def get_per_upload_rate_limit(self, unique_ID):

View file

@ -508,7 +508,7 @@ static PyObject *torrent_set_per_upload_rate_limit(PyObject *self, PyObject *arg
return NULL; return NULL;
if (M_torrents->at(index).handle.is_valid()) if (M_torrents->at(index).handle.is_valid())
M_torrents->at(index).handle.set_upload_limit(speed); M_torrents->at(index).handle.set_upload_limit(speed * 1024);
Py_INCREF(Py_None); return Py_None; Py_INCREF(Py_None); return Py_None;
} }
@ -538,7 +538,7 @@ static PyObject *torrent_set_per_download_rate_limit(PyObject *self, PyObject *a
if (PyErr_Occurred()) if (PyErr_Occurred())
return NULL; return NULL;
if (M_torrents->at(index).handle.is_valid()) if (M_torrents->at(index).handle.is_valid())
M_torrents->at(index).handle.set_download_limit(speed); M_torrents->at(index).handle.set_download_limit(speed * 1024);
Py_INCREF(Py_None); return Py_None; Py_INCREF(Py_None); return Py_None;
} }