diff --git a/app/monitor.py b/app/monitor.py index 51e91276..79878c2e 100644 --- a/app/monitor.py +++ b/app/monitor.py @@ -149,14 +149,17 @@ class Monitor(metaclass=Singleton): if mon_dir.storage == "local": # 本地目录监控 try: - observer = self.__choose_observer() + if mon_dir.monitor_mode == "fast": + observer = self.__choose_observer() + else: + observer = PollingObserver() self._observers.append(observer) observer.schedule(FileMonitorHandler(mon_path=mon_path, callback=self), - path=mon_path, + path=str(mon_path), recursive=True) observer.daemon = True observer.start() - logger.info(f"已启动 {mon_path} 的目录监控服务") + logger.info(f"已启动 {mon_path} 的目录监控服务, 监控模式:{mon_dir.monitor_mode}") except Exception as e: err_msg = str(e) if "inotify" in err_msg and "reached" in err_msg: diff --git a/app/schemas/system.py b/app/schemas/system.py index 3680957f..894466d7 100644 --- a/app/schemas/system.py +++ b/app/schemas/system.py @@ -113,6 +113,8 @@ class TransferDirectoryConf(BaseModel): download_category_folder: Optional[bool] = False # 监控方式 downloader/monitor,None为不监控 monitor_type: Optional[str] = None + # 监控模式 fast / compatibility + monitor_mode: Optional[str] = 'fast' # 整理方式 move/copy/link/softlink transfer_type: Optional[str] = None # 文件覆盖模式 always/size/never/latest