diff options
Diffstat (limited to 'kvmd/plugins/msd/__init__.py')
-rw-r--r-- | kvmd/plugins/msd/__init__.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/kvmd/plugins/msd/__init__.py b/kvmd/plugins/msd/__init__.py index 11cd8be5..8b5fa8e2 100644 --- a/kvmd/plugins/msd/__init__.py +++ b/kvmd/plugins/msd/__init__.py @@ -266,9 +266,6 @@ class MsdFileWriter(BaseMsdWriter): # pylint: disable=too-many-instance-attribu return self.__written - def is_complete(self) -> bool: - return (self.__written >= self.__file_size) - async def open(self) -> "MsdFileWriter": assert self.__file is None get_logger(1).info("Writing %r image (%d bytes) to MSD ...", self.__name, self.__file_size) @@ -276,6 +273,10 @@ class MsdFileWriter(BaseMsdWriter): # pylint: disable=too-many-instance-attribu self.__file = await aiofiles.open(self.__path, mode="w+b", buffering=0) # type: ignore return self + async def finish(self) -> bool: + await self.__sync() + return (self.__written >= self.__file_size) + async def close(self) -> None: assert self.__file is not None logger = get_logger() @@ -288,10 +289,7 @@ class MsdFileWriter(BaseMsdWriter): # pylint: disable=too-many-instance-attribu else: # written > size (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 self.__sync() - finally: - await self.__file.close() # type: ignore + await self.__file.close() # type: ignore except Exception: logger.exception("Can't close image writer") |