Skip to content

Resolve long standing issue which prevents proper refresh of stats file data. #13348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions kolibri/core/webpack/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand All @@ -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
Expand Down