Skip to content

Commit

Permalink
Fixed race condition in privacy plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Oct 14, 2024
1 parent 39d14d5 commit 92089c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions material/plugins/privacy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ def on_files(self, files, *, config):
# 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
Expand Down Expand Up @@ -149,6 +147,10 @@ def on_page_content(self, html, *, page, config, files):
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):
Expand Down
12 changes: 7 additions & 5 deletions src/plugins/privacy/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ def on_files(self, files, *, config):
# 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
Expand Down Expand Up @@ -149,6 +147,10 @@ def on_page_content(self, html, *, page, config, files):
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):
Expand Down

0 comments on commit 92089c6

Please sign in to comment.