fix 'compile_html_file' to use dirs_exist_ok

5065efd3 incorrectly changed to doing an rmtree of the entire target
since that was what editionify needed. Editionify should clean the
target directory, but the single HTML file build should not (it ended up
wiping my git repository from my hard drive). We might wish to revisit
this particular fix in the future since it still fails to delete removed
extimages, but this doesn't seem like a big deal.
This commit is contained in:
Soren I. Bjornstad 2021-09-21 21:12:36 -05:00
parent 9a70b67af7
commit ec83de9978

View File

@ -278,7 +278,8 @@ def compile_html_file(
will be placed, relative to the private wiki's root directory.
Default ``output/public_site``.
:param overwrite: If the ``output_folder`` already exists,
should we overwrite it? Default True.
should we overwrite any files in it with the same name?
Default True.
:param externalize_attachments: If True, update tiddlers that match
the ``attachment_filter`` parameter to point to
external versions of their content.
@ -311,13 +312,10 @@ def compile_html_file(
f"(To overwrite any files existing in the output folder, "
f"set overwrite = True for this builder.)")
try:
shutil.rmtree(output_folder)
except FileNotFoundError:
pass
shutil.copytree(
Path(build_state['public_wiki_folder']) / "output",
Path(output_folder),
dirs_exist_ok=True
)
info(f"Successfully copied built output to {os.path.abspath(output_folder)}.")