fix: live preview rebuilds no longer crash the server

When cleaning the previous build, we deleted the entire directory, which
caused problems. Now, we only clean the output dir's children, but leave
the dir itself intact.
This commit is contained in:
Daniel Fichtinger 2025-07-13 03:13:58 -04:00
parent 8d17572d12
commit dacea2756a

View file

@ -145,7 +145,13 @@ class ZonaBuilder:
and self.layout.output.is_dir()
):
logger.debug("Removing stale output...")
shutil.rmtree(self.layout.output)
# only remove output dir's children
# to avoid breaking live preview
for child in self.layout.output.iterdir():
if child.is_file() or child.is_symlink():
child.unlink()
elif child.is_dir():
shutil.rmtree(child)
logger.debug("Discovering...")
self._discover()
logger.debug("Building...")