diff options
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/inotify.py | 17 | ||||
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 7 | ||||
-rw-r--r-- | kvmd/plugins/ugpio/otgconf.py | 4 |
3 files changed, 13 insertions, 15 deletions
diff --git a/kvmd/inotify.py b/kvmd/inotify.py index fe9b6391..b66ca443 100644 --- a/kvmd/inotify.py +++ b/kvmd/inotify.py @@ -190,14 +190,15 @@ class Inotify: self.__events_queue: "asyncio.Queue[InotifyEvent]" = asyncio.Queue() - async def watch(self, path: str, mask: int) -> None: - path = os.path.normpath(path) - assert path not in self.__wd_by_path, path - get_logger().info("Watching for %s", path) - # Асинхронно, чтобы не висло на NFS - wd = _inotify_check(await aiotools.run_async(libc.inotify_add_watch, self.__fd, _fs_encode(path), mask)) - self.__wd_by_path[path] = wd - self.__path_by_wd[wd] = path + async def watch(self, mask: int, *paths: str) -> None: + for path in paths: + path = os.path.normpath(path) + assert path not in self.__wd_by_path, path + get_logger().info("Watching for %s", path) + # Асинхронно, чтобы не висло на NFS + wd = _inotify_check(await aiotools.run_async(libc.inotify_add_watch, self.__fd, _fs_encode(path), mask)) + self.__wd_by_path[path] = wd + self.__path_by_wd[wd] = path # def unwatch(self, path: str) -> None: # path = os.path.normpath(path) diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index d8175975..d286fc84 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -417,11 +417,8 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes await asyncio.sleep(5) with Inotify() as inotify: - for path in [ - *self.__storage.get_watchable_paths(), - *self.__drive.get_watchable_paths(), - ]: - await inotify.watch(path, InotifyMask.ALL_MODIFY_EVENTS) + await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, *self.__storage.get_watchable_paths()) + await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, *self.__drive.get_watchable_paths()) # После установки вотчеров еще раз проверяем стейт, чтобы ничего не потерять await self.__reload_state() diff --git a/kvmd/plugins/ugpio/otgconf.py b/kvmd/plugins/ugpio/otgconf.py index 194475c3..a2604c98 100644 --- a/kvmd/plugins/ugpio/otgconf.py +++ b/kvmd/plugins/ugpio/otgconf.py @@ -82,8 +82,8 @@ class Plugin(BaseUserGpioDriver): await asyncio.sleep(5) with Inotify() as inotify: - await inotify.watch(os.path.dirname(self.__udc_path), InotifyMask.ALL_MODIFY_EVENTS) - await inotify.watch(self.__profile_path, InotifyMask.ALL_MODIFY_EVENTS) + await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, os.path.dirname(self.__udc_path)) + await inotify.watch(InotifyMask.ALL_MODIFY_EVENTS, self.__profile_path) self._notifier.notify() while True: need_restart = False |