From d839fd76e62d47b091c9b83513dde6b0e357cf52 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 22 Apr 2025 11:11:41 -0700 Subject: [PATCH] Resolve long standing issue which prevents proper refresh of stats file data. --- kolibri/core/webpack/hooks.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kolibri/core/webpack/hooks.py b/kolibri/core/webpack/hooks.py index b313f3e34eb..7ed63f24ed6 100644 --- a/kolibri/core/webpack/hooks.py +++ b/kolibri/core/webpack/hooks.py @@ -20,7 +20,6 @@ from django.contrib.staticfiles.finders import find as find_staticfiles from django.contrib.staticfiles.storage import staticfiles_storage from django.core.serializers.json import DjangoJSONEncoder -from django.utils.functional import cached_property from django.utils.safestring import mark_safe from django.utils.translation import get_language from django.utils.translation import get_language_info @@ -79,15 +78,19 @@ def get_by_unique_id(cls, unique_id): return hook raise WebpackError("No bundle with that name is loaded: '{}'".format(unique_id)) - @cached_property + @property def _stats_file_content(self): """ :returns: A dict of the data contained in the JSON files which are written by Webpack. """ + DEVELOPER_MODE = getattr(settings, "DEVELOPER_MODE", False) + if hasattr(self, "_cached_stats_file_content") and not DEVELOPER_MODE: + return self._cached_stats_file_content + stats = self.get_stats() - if getattr(settings, "DEVELOPER_MODE", False): + if DEVELOPER_MODE: timeout = 0 while stats["status"] == "compile": @@ -106,6 +109,8 @@ def _stats_file_content(self): "files": stats.get("chunks", {}).get(self.unique_id, []), } + self._cached_stats_file_content = stats_file_content + return stats_file_content @property