1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2025-12-07 15:02:55 +08:00

fix: 文件监控: 忽略非文件创建、删除和移动事件 (#514)

只处理文件创建、删除和移动事件,避免处理不必要的事件类型
This commit is contained in:
AisukaYuki
2025-07-23 12:31:34 +08:00
committed by GitHub
parent f27e5299a8
commit b547fa08da

View File

@@ -15,7 +15,7 @@ from logging.handlers import RotatingFileHandler
from aiohttp import ClientSession, ClientTimeout
from miservice import MiAccount, MiIOService, MiNAService, miio_command
from watchdog.events import FileSystemEventHandler
from watchdog.events import FileSystemEventHandler, FileCreatedEvent, FileDeletedEvent, FileMovedEvent
from watchdog.observers import Observer
from xiaomusic import __version__
@@ -2207,6 +2207,10 @@ class XiaoMusicPathWatch(FileSystemEventHandler):
self._debounce_handle = None
def on_any_event(self, event):
# 只处理文件的创建、删除和移动事件
if not isinstance(event, (FileCreatedEvent, FileDeletedEvent, FileMovedEvent)):
return
if event.is_directory:
return # 忽略目录事件