[Pkg-sugar-commit] [sugar-browse-activity] 01/05: Download: update progress only when the percent changes - #4619
Jonas Smedegaard
dr at jones.dk
Mon Apr 20 09:47:54 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag v149.4
in repository sugar-browse-activity.
commit 2027f362baf7006b73df5854b314b9cabf33c8dc
Author: Manuel Quiñones <manuq at laptop.org>
Date: Wed Sep 4 16:37:13 2013 -0300
Download: update progress only when the percent changes - #4619
Fixes #4619 . Too much calls to datastore.write() is ineffective.
---
downloadmanager.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/downloadmanager.py b/downloadmanager.py
index b807959..cf72a2c 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -96,16 +96,20 @@ class Download(object):
self._download.start()
def __progress_change_cb(self, download, something):
- progress = self._download.get_progress()
- self.dl_jobject.metadata['progress'] = str(int(progress * 100))
- datastore.write(self.dl_jobject)
+ progress = int(self._download.get_progress() * 100)
+ if progress > self._last_update_percent:
+ self._last_update_percent = progress
+ self.dl_jobject.metadata['progress'] = str(progress)
+ datastore.write(self.dl_jobject)
def __current_size_changed_cb(self, download, something):
current_size = self._download.get_current_size()
total_size = self._download.get_total_size()
- progress = current_size * 100 / total_size
- self.dl_jobject.metadata['progress'] = str(progress)
- datastore.write(self.dl_jobject)
+ progress = int(current_size * 100 / total_size)
+ if progress > self._last_update_percent:
+ self._last_update_percent = progress
+ self.dl_jobject.metadata['progress'] = str(progress)
+ datastore.write(self.dl_jobject)
def __state_change_cb(self, download, gparamspec):
state = self._download.get_status()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-sugar/sugar-browse-activity.git
More information about the pkg-sugar-commit
mailing list