diff options
author | Maxim Devaev <[email protected]> | 2022-07-23 09:57:11 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-07-24 05:38:26 +0300 |
commit | 44ffe83199b464f7515eee7a850d360522b826e2 (patch) | |
tree | 59c8cab642f00c0706048927c594d7c0e1b94892 /kvmd/plugins | |
parent | 477e6f05e44d3c83ff19a97f1454ac1ba9191e70 (diff) |
renamed new_writer to writer
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/msd/otg/__init__.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py index f04d5084..29694ed3 100644 --- a/kvmd/plugins/msd/otg/__init__.py +++ b/kvmd/plugins/msd/otg/__init__.py @@ -162,8 +162,8 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes self.__drive = Drive(gadget, instance=0, lun=0) - self.__new_writer: Optional[MsdImageWriter] = None - self.__new_writer_tick = 0.0 + self.__writer: Optional[MsdImageWriter] = None + self.__writer_tick = 0.0 self.__notifier = aiotools.AioNotifier() self.__state = _State(self.__notifier) @@ -200,9 +200,9 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes del storage["images"][name]["path"] del storage["images"][name]["in_storage"] - if self.__new_writer: + if self.__writer: # При загрузке файла показываем актуальную статистику вручную - storage["uploading"] = self.__new_writer.get_state() + storage["uploading"] = self.__writer.get_state() space = fs.get_fs_space(self.__storage_path, fatal=False) if space: storage.update(dataclasses.asdict(space)) @@ -253,7 +253,7 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes @aiotools.atomic async def cleanup(self) -> None: - await self.__close_new_writer() + await self.__close_writer() # ===== @@ -337,14 +337,14 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes await self.__remount_rw(True) self.__set_image_complete(name, False) - self.__new_writer = await MsdImageWriter(path, size, self.__sync_chunk_size).open() + self.__writer = await MsdImageWriter(path, size, self.__sync_chunk_size).open() await self.__notifier.notify() yield self.__upload_chunk_size self.__set_image_complete(name, True) finally: - await self.__close_new_writer() + await self.__close_writer() await self.__remount_rw(False, fatal=False) finally: # Между закрытием файла и эвентом айнотифи состояние может быть не обновлено, @@ -353,12 +353,12 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes await self.__notifier.notify() async def write_image_chunk(self, chunk: bytes) -> int: - assert self.__new_writer - written = await self.__new_writer.write(chunk) + assert self.__writer + written = await self.__writer.write(chunk) now = time.monotonic() - if self.__new_writer_tick + 1 < now: + if self.__writer_tick + 1 < now: # Это нужно для ручного оповещения о свободном пространстве на диске, см. get_state() - self.__new_writer_tick = now + self.__writer_tick = now await self.__notifier.notify() return written @@ -387,15 +387,15 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes # ===== - async def __close_new_writer(self) -> None: + async def __close_writer(self) -> None: try: - if self.__new_writer: + if self.__writer: get_logger().info("Closing new image file ...") - await self.__new_writer.close() + await self.__writer.close() except Exception: get_logger().exception("Can't close image file") finally: - self.__new_writer = None + self.__writer = None # ===== |