Skip to content

Commit be9f415

Browse files
committed
don't crash when tracked file is deleted
1 parent 43fa733 commit be9f415

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

jinja2html/__main__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ def __base_update_handler(self, event):
164164
if event.is_directory:
165165
return
166166

167+
# skip deleted/non-existent paths
168+
if not (path := Path(event.src_path)).exists():
169+
logging.warning("Observed change to non-existent path, %s, doing nothing", path)
170+
return
171+
167172
# do not process output files if in a nested dir
168-
path = Path(event.src_path)
169173
if STATIC_SERVER_ROOT in path.parents or any(d in IGNORED_DIRS for d in path.parents):
170174
return
171175

@@ -246,8 +250,7 @@ def build_html(path):
246250
integrity="sha512-DSycG/J5pRCjy6wZ8nfeqaKuSAf9jVmSulTuzy1xQL+2yyBIp7fwzNvx+tZCtZ6kIRMqiDyWOYSl4zYjT32zOw==", crossorigin="anonymous"))
247251
output = str(soup)
248252
except AttributeError:
249-
output = f"ERROR: Malformed or non-existent html in '{path}'. Doing nothing."
250-
logging.error(output)
253+
logging.warning(output := f"Malformed or non-existent html in '{path}'. Doing nothing.")
251254

252255
resolve_output_path(path).write_text(output)
253256

0 commit comments

Comments
 (0)