From 6ec6b41f3f7d278db4d6cbf715226993ea90c0e2 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Tue, 19 Mar 2024 07:39:20 -0700 Subject: [PATCH] Limit progress integers to less than or equal to 10000 --- src/android_app_plugin/kolibri_plugin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/android_app_plugin/kolibri_plugin.py b/src/android_app_plugin/kolibri_plugin.py index 7a136f5..4439009 100644 --- a/src/android_app_plugin/kolibri_plugin.py +++ b/src/android_app_plugin/kolibri_plugin.py @@ -9,6 +9,7 @@ Locale = autoclass("java.util.Locale") Task = autoclass("org.learningequality.Task") +PROGRESS_LIMIT = 10000 logger = logging.getLogger(__name__) @@ -68,6 +69,13 @@ def update(self, job, orm_job, state=None, **kwargs): else: progress = -1 total_progress = -1 + + # avoid passing integers that are too large + # PROGRESS_LIMIT gives sufficient precision for a % progress calculation + if total_progress > PROGRESS_LIMIT: + progress = progress // total_progress * PROGRESS_LIMIT + total_progress = PROGRESS_LIMIT + Task.updateProgress( orm_job.worker_extra, status.title,