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:
parent
8d17572d12
commit
e5fa7e85fc
2 changed files with 8 additions and 1 deletions
|
@ -145,7 +145,13 @@ class ZonaBuilder:
|
||||||
and self.layout.output.is_dir()
|
and self.layout.output.is_dir()
|
||||||
):
|
):
|
||||||
logger.debug("Removing stale output...")
|
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...")
|
logger.debug("Discovering...")
|
||||||
self._discover()
|
self._discover()
|
||||||
logger.debug("Building...")
|
logger.debug("Building...")
|
||||||
|
|
|
@ -4,6 +4,7 @@ import signal
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from types import FrameType
|
from types import FrameType
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue