diff options
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/msd/__init__.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/kvmd/plugins/msd/__init__.py b/kvmd/plugins/msd/__init__.py index 65da192c..69be26bc 100644 --- a/kvmd/plugins/msd/__init__.py +++ b/kvmd/plugins/msd/__init__.py @@ -36,7 +36,6 @@ from ...errors import OperationError from ...errors import IsBusyError from ... import aiotools -from ... import aiofs from .. import BasePlugin from .. import get_plugin_class @@ -254,7 +253,7 @@ class MsdFileWriter(BaseMsdWriter): # pylint: disable=too-many-instance-attribu self.__unsynced += len(chunk) if self.__unsynced >= self.__sync_size: - await aiofs.afile_sync(self.__file) + await self.__sync() self.__unsynced = 0 now = time.monotonic() @@ -287,12 +286,17 @@ class MsdFileWriter(BaseMsdWriter): # pylint: disable=too-many-instance-attribu (log, result) = (logger.warning, "OVERFLOW") log("Written %d of %d bytes to MSD image %r: %s", self.__written, self.__file_size, self.__name, result) try: - await aiofs.afile_sync(self.__file) + await self.__sync() finally: await self.__file.close() # type: ignore except Exception: logger.exception("Can't close image writer") + async def __sync(self) -> None: + assert self.__file is not None + await self.__file.flush() # type: ignore + await aiotools.run_async(os.fsync, self.__file.fileno()) # type: ignore + # ===== def get_msd_class(name: str) -> type[BaseMsd]: |