Skip to content

Commit 92089c6

Browse files
committed
Fixed race condition in privacy plugin
1 parent 39d14d5 commit 92089c6

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

material/plugins/privacy/plugin.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ def on_files(self, files, *, config):
9696
# automatically loads Mermaid.js when a Mermaid diagram is
9797
# found in the page - https://bit.ly/36tZXsA.
9898
if "mermaid.min.js" in url.path and not config.site_url:
99-
path = url.geturl()
100-
if path not in config.extra_javascript:
101-
config.extra_javascript.append(
102-
ExtraScriptValue(path)
103-
)
99+
script = ExtraScriptValue(url.geturl())
100+
if script not in config.extra_javascript:
101+
config.extra_javascript.append(script)
104102

105103
# The local asset references at least one external asset, which
106104
# means we must download and replace them later
@@ -149,6 +147,10 @@ def on_page_content(self, html, *, page, config, files):
149147
if not self._is_excluded(url, page.file):
150148
self._queue(url, config, concurrent = True)
151149

150+
# Sync all concurrent jobs
151+
def on_env(self, env, *, config, files):
152+
wait(self.pool_jobs)
153+
152154
# Process external assets in template (run later)
153155
@event_priority(-50)
154156
def on_post_template(self, output_content, *, template_name, config):

src/plugins/privacy/plugin.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ def on_files(self, files, *, config):
9696
# automatically loads Mermaid.js when a Mermaid diagram is
9797
# found in the page - https://bit.ly/36tZXsA.
9898
if "mermaid.min.js" in url.path and not config.site_url:
99-
path = url.geturl()
100-
if path not in config.extra_javascript:
101-
config.extra_javascript.append(
102-
ExtraScriptValue(path)
103-
)
99+
script = ExtraScriptValue(url.geturl())
100+
if script not in config.extra_javascript:
101+
config.extra_javascript.append(script)
104102

105103
# The local asset references at least one external asset, which
106104
# means we must download and replace them later
@@ -149,6 +147,10 @@ def on_page_content(self, html, *, page, config, files):
149147
if not self._is_excluded(url, page.file):
150148
self._queue(url, config, concurrent = True)
151149

150+
# Sync all concurrent jobs
151+
def on_env(self, env, *, config, files):
152+
wait(self.pool_jobs)
153+
152154
# Process external assets in template (run later)
153155
@event_priority(-50)
154156
def on_post_template(self, output_content, *, template_name, config):

0 commit comments

Comments
 (0)