From 6ca78c0cb92a19afe9274bcfb1efc075c5bf1aae Mon Sep 17 00:00:00 2001 From: thsrite Date: Wed, 23 Oct 2024 11:35:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E7=9B=AE=E5=BD=95=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E7=9B=91=E6=8E=A7=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/monitor.py | 9 ++++++--- app/schemas/system.py | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) 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