Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel QuiƱones <manuq@laptop.org>2013-09-04 19:37:13 (GMT)
committer Manuel QuiƱones <manuq@laptop.org>2013-09-04 19:40:17 (GMT)
commit2027f362baf7006b73df5854b314b9cabf33c8dc (patch)
tree45d8831e2e381df576dd0e5e777ad0d96e0c5a51
parent9a6551b50380b442736419feb717efd0954dd362 (diff)
Download: update progress only when the percent changes - #4619
Fixes #4619 . Too much calls to datastore.write() is ineffective.
-rw-r--r--downloadmanager.py16
1 files 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()