send_custom_email: Use a special .gitignored directory.

Previously, the send_custom_email code path leaked files in paths that
were not `.gitignored`, under templates/zerver/emails.

This became problematic when we added automated tests for this code
path, as it meant we leaked these files every time `test-backend` ran.

Fix this by ensuring all the files we generate are in this special
subdirectory.
This commit is contained in:
Tim Abbott
2020-04-21 16:48:28 -07:00
parent b5f2ba5566
commit 703fae8980
3 changed files with 8 additions and 6 deletions

View File

@@ -29,12 +29,12 @@ def configure_cssutils() -> None:
configure_cssutils()
def inline_template(template_source_name: str) -> None:
os.makedirs(COMPILED_EMAIL_TEMPLATES_PATH, exist_ok=True)
template_name = template_source_name.split('.source.html')[0]
compiled_template_path = os.path.join(COMPILED_EMAIL_TEMPLATES_PATH,
template_name + ".html")
template_path = os.path.join(EMAIL_TEMPLATES_PATH, template_source_name)
compiled_template_path = os.path.join(os.path.dirname(template_path), "compiled",
os.path.basename(template_name) + ".html")
os.makedirs(os.path.dirname(compiled_template_path), exist_ok=True)
with open(template_path) as template_source_file:
template_str = template_source_file.read()