fix(hotreload): verify that a file path exists before creating an observer schedule for it
Some checks failed
Actions / Build Documentation (MkDocs) (push) Successful in 47s
Actions / Lint Code (Ruff & Pylint) (push) Failing after 52s

This commit is contained in:
cswimr 2025-01-26 21:29:02 +00:00
parent 70d75c688c
commit 5c6783452d
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087

View file

@ -19,7 +19,7 @@ class HotReload(commands.Cog):
__author__ = ["[cswimr](https://www.coastalcommits.com/cswimr)"]
__git__ = "https://www.coastalcommits.com/cswimr/SeaCogs"
__version__ = "1.3.1"
__version__ = "1.3.2"
__documentation__ = "https://seacogs.coastalcommits.com/hotreload/"
def __init__(self, bot: Red) -> None:
@ -73,6 +73,10 @@ class HotReload(commands.Cog):
self.logger.debug("Stopped hanging observer.")
continue
for path in paths:
if not path.exists():
self.logger.warning("Path %s does not exist. Skipping.", path)
continue
self.logger.debug("Adding observer schedule for path %s.", path)
observer.schedule(event_handler=HotReloadHandler(cog=self, path=path), path=path, recursive=True)
observer.start()
self.logger.info("Started observer. Watching for file changes.")