1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-23 23:21:00 +01:00

Fixed race condition in privacy plugin

This commit is contained in:
squidfunk 2024-10-14 14:41:35 +02:00
parent 39d14d5c19
commit 92089c67f1
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
2 changed files with 14 additions and 10 deletions

View File

@ -96,11 +96,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
# automatically loads Mermaid.js when a Mermaid diagram is
# found in the page - https://bit.ly/36tZXsA.
if "mermaid.min.js" in url.path and not config.site_url:
path = url.geturl()
if path not in config.extra_javascript:
config.extra_javascript.append(
ExtraScriptValue(path)
)
script = ExtraScriptValue(url.geturl())
if script not in config.extra_javascript:
config.extra_javascript.append(script)
# The local asset references at least one external asset, which
# means we must download and replace them later
@ -149,6 +147,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not self._is_excluded(url, page.file):
self._queue(url, config, concurrent = True)
# Sync all concurrent jobs
def on_env(self, env, *, config, files):
wait(self.pool_jobs)
# Process external assets in template (run later)
@event_priority(-50)
def on_post_template(self, output_content, *, template_name, config):

View File

@ -96,11 +96,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
# automatically loads Mermaid.js when a Mermaid diagram is
# found in the page - https://bit.ly/36tZXsA.
if "mermaid.min.js" in url.path and not config.site_url:
path = url.geturl()
if path not in config.extra_javascript:
config.extra_javascript.append(
ExtraScriptValue(path)
)
script = ExtraScriptValue(url.geturl())
if script not in config.extra_javascript:
config.extra_javascript.append(script)
# The local asset references at least one external asset, which
# means we must download and replace them later
@ -149,6 +147,10 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]):
if not self._is_excluded(url, page.file):
self._queue(url, config, concurrent = True)
# Sync all concurrent jobs
def on_env(self, env, *, config, files):
wait(self.pool_jobs)
# Process external assets in template (run later)
@event_priority(-50)
def on_post_template(self, output_content, *, template_name, config):