From ec83de9978e281904254b67db9db82a77ba3e640 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 21 Sep 2021 21:12:36 -0500 Subject: [PATCH] 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. --- tzk/builders.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tzk/builders.py b/tzk/builders.py index f8d369e..1e5eb24 100644 --- a/tzk/builders.py +++ b/tzk/builders.py @@ -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)}.")