From d744f73552964362d2c2580530e9a1fdf4649afa Mon Sep 17 00:00:00 2001 From: xerdream Date: Wed, 13 Aug 2025 15:25:07 +0800 Subject: [PATCH] Fix file watching not working due to relative paths --- app/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index 3ba5ae4..20c399f 100644 --- a/app/main.py +++ b/app/main.py @@ -74,6 +74,10 @@ class Config: if not self.URL_PREFIX.endswith('/'): self.URL_PREFIX += '/' + # Convert relative addresses to absolute addresses to prevent the failure of file address comparison + if self.YTDL_OPTIONS_FILE and self.YTDL_OPTIONS_FILE.startswith('.'): + self.YTDL_OPTIONS_FILE = str(Path(self.YTDL_OPTIONS_FILE).resolve()) + success,_ = self.load_ytdl_options() if not success: sys.exit(1) @@ -183,14 +187,13 @@ def get_options_update_time(success=True, msg=''): return result async def watch_files(): - path_to_watch = Path(config.YTDL_OPTIONS_FILE).resolve() async def _watch_files(): - async for changes in awatch(path_to_watch, watch_filter=FileOpsFilter()): + async for changes in awatch(config.YTDL_OPTIONS_FILE, watch_filter=FileOpsFilter()): success, msg = config.load_ytdl_options() result = get_options_update_time(success, msg) await sio.emit('ytdl_options_changed', serializer.encode(result)) - log.info(f'Starting Watch File: {path_to_watch}') + log.info(f'Starting Watch File: {config.YTDL_OPTIONS_FILE}') asyncio.create_task(_watch_files()) if config.YTDL_OPTIONS_FILE: