Merge pull request #2911 from thsrite/v2

This commit is contained in:
jxxghp
2024-10-23 11:45:10 +08:00
committed by GitHub
2 changed files with 8 additions and 3 deletions

View File

@@ -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:

View File

@@ -113,6 +113,8 @@ class TransferDirectoryConf(BaseModel):
download_category_folder: Optional[bool] = False
# 监控方式 downloader/monitorNone为不监控
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