only write if file changed (#4822)

* only write if file changed

* preface it on it existing
This commit is contained in:
Khaleel Al-Adhami 2025-02-13 22:49:27 -08:00 committed by GitHub
parent 7c4257a222
commit 10bae9577c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -523,6 +523,8 @@ def write_page(path: str | Path, code: str):
"""
path = Path(path)
path_ops.mkdir(path.parent)
if path.exists() and path.read_text(encoding="utf-8") == code:
return
path.write_text(code, encoding="utf-8")