From f20b6c925483b8e489a377f760d5c75f017cb39f Mon Sep 17 00:00:00 2001 From: ericwyuan Date: Fri, 21 Aug 2026 11:28:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(fam-edge):=20WatchProcessor=20=E9=80=92?= =?UTF-8?q?=E5=BD=92=E6=89=AB=E6=8F=8F=E5=AD=90=E7=9B=AE=E5=BD=95=EF=BC=88?= =?UTF-8?q?GDrive=20=E5=BD=95=E5=83=8F=E6=8C=89=20YYYYMMDDAM/PM=20?= =?UTF-8?q?=E5=AD=90=E7=9B=AE=E5=BD=95=E7=BB=84=E7=BB=87=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fam-edge/src/fam_edge/watch_processor.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fam-edge/src/fam_edge/watch_processor.py b/fam-edge/src/fam_edge/watch_processor.py index c79602f..6e4f023 100644 --- a/fam-edge/src/fam_edge/watch_processor.py +++ b/fam-edge/src/fam_edge/watch_processor.py @@ -35,19 +35,21 @@ class WatchProcessor: self._thread = None def _scan_files(self) -> List[str]: + """递归扫描监听目录,返回所有视频文件的完整路径""" if not os.path.isdir(self.local_dir): logger.warning(f"监听目录不存在: {self.local_dir}") return [] out = [] - for fn in sorted(os.listdir(self.local_dir)): - if fn.lower().endswith(VIDEO_EXTS): - out.append(fn) + for root, _dirs, files in os.walk(self.local_dir): + for fn in sorted(files): + if fn.lower().endswith(VIDEO_EXTS): + out.append(os.path.join(root, fn)) return out def _register_new(self, files: List[str]): - for fn in files: + for path in files: + fn = os.path.basename(path) if self.db.get_video_by_filename(fn) is None: - path = os.path.join(self.local_dir, fn) self.db.ensure_video(fn, path, camera_name=self.camera_name) logger.info(f"登记新视频: {fn}")