From 523922b3837ca974346a012191991d89f4030f68 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Sat, 1 Mar 2025 13:22:03 +0700 Subject: [PATCH] Fixed privacy plugin not replacing occurrences --- material/plugins/privacy/plugin.py | 5 ++++- src/plugins/privacy/plugin.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/material/plugins/privacy/plugin.py b/material/plugins/privacy/plugin.py index fc47fcada..106b9d203 100644 --- a/material/plugins/privacy/plugin.py +++ b/material/plugins/privacy/plugin.py @@ -433,7 +433,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): # Intercept errors of type `ConnectionError` and `HTTPError` except Exception as error: log.warning(f"Couldn't retrieve {file.url}: {error}") - return + return False # Compute expected file extension and append if missing mime = res.headers["content-type"].split(";")[0] @@ -484,6 +484,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): if not self._is_excluded(url, file): self._queue(url, config, concurrent = True) + # External asset was successfully downloaded + return True + # Patch all links to external assets in the given file def _patch(self, initiator: File): with open(initiator.abs_src_path, encoding = "utf-8-sig") as f: diff --git a/src/plugins/privacy/plugin.py b/src/plugins/privacy/plugin.py index fc47fcada..106b9d203 100644 --- a/src/plugins/privacy/plugin.py +++ b/src/plugins/privacy/plugin.py @@ -433,7 +433,7 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): # Intercept errors of type `ConnectionError` and `HTTPError` except Exception as error: log.warning(f"Couldn't retrieve {file.url}: {error}") - return + return False # Compute expected file extension and append if missing mime = res.headers["content-type"].split(";")[0] @@ -484,6 +484,9 @@ class PrivacyPlugin(BasePlugin[PrivacyConfig]): if not self._is_excluded(url, file): self._queue(url, config, concurrent = True) + # External asset was successfully downloaded + return True + # Patch all links to external assets in the given file def _patch(self, initiator: File): with open(initiator.abs_src_path, encoding = "utf-8-sig") as f: