From e9b8c0d01ee22108f8bc654d37644a8186bd15a9 Mon Sep 17 00:00:00 2001 From: GeoffreyCoulaud Date: Fri, 30 Jun 2023 13:57:22 +0200 Subject: [PATCH] Fixed importer progressbar stuck at 100% - Progress is 0 by default - 10% for the sources progress - 90% for the pipelines progress --- src/importer/importer.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/importer/importer.py b/src/importer/importer.py index 0f909c9..024283c 100644 --- a/src/importer/importer.py +++ b/src/importer/importer.py @@ -67,7 +67,15 @@ class Importer(ErrorProducer): try: progress = progress / len(self.game_pipelines) except ZeroDivisionError: - progress = 1 + progress = 0 + return progress + + @property + def sources_progress(self): + try: + progress = self.n_source_tasks_done / self.n_source_tasks_created + except ZeroDivisionError: + progress = 0 return progress @property @@ -175,8 +183,11 @@ class Importer(ErrorProducer): self.game_pipelines.add(pipeline) def update_progressbar(self): - """Update the progressbar to show the percentage of game pipelines done""" - self.progressbar.set_fraction(self.pipelines_progress) + """Update the progressbar to show the overall import progress""" + # Reserve 10% for the sources discovery, the rest is the pipelines + self.progressbar.set_fraction( + (0.1 * self.sources_progress) + (0.9 * self.pipelines_progress) + ) def source_callback(self, _obj, _result, data): """Callback executed when a source is fully scanned"""