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}")