summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-10-24 03:05:46 +0300
committerMaxim Devaev <[email protected]>2024-10-24 03:05:46 +0300
commit399712c6849b52efcb1b1ee9f4abdafa84c5812f (patch)
tree605c765b187b7a15989c2c10ed37a5266f9d03c2
parent1ebc08eae849d06ecf42e6e2e60d7fd6d60ae9c6 (diff)
refactoring
-rw-r--r--kvmd/plugins/msd/otg/__init__.py3
-rw-r--r--kvmd/plugins/msd/otg/storage.py13
2 files changed, 4 insertions, 12 deletions
diff --git a/kvmd/plugins/msd/otg/__init__.py b/kvmd/plugins/msd/otg/__init__.py
index 0bb9f489..7c2c7a9e 100644
--- a/kvmd/plugins/msd/otg/__init__.py
+++ b/kvmd/plugins/msd/otg/__init__.py
@@ -179,6 +179,9 @@ class Plugin(BaseMsd): # pylint: disable=too-many-instance-attributes
for name in list(storage["parts"]):
del storage["parts"][name]["name"]
+ storage["size"] = storage["parts"][""]["size"] # Legacy API
+ storage["free"] = storage["parts"][""]["free"] # Legacy API
+
storage["downloading"] = (self.__reader.get_state() if self.__reader else None)
storage["uploading"] = (self.__writer.get_state() if self.__writer else None)
diff --git a/kvmd/plugins/msd/otg/storage.py b/kvmd/plugins/msd/otg/storage.py
index f3679741..046f10fa 100644
--- a/kvmd/plugins/msd/otg/storage.py
+++ b/kvmd/plugins/msd/otg/storage.py
@@ -169,8 +169,6 @@ class _Part(_PartDc):
# =====
@dataclasses.dataclass(frozen=True, eq=False)
class _StorageDc:
- size: int = dataclasses.field(init=False)
- free: int = dataclasses.field(init=False)
images: dict[str, Image] = dataclasses.field(init=False)
parts: dict[str, _Part] = dataclasses.field(init=False)
@@ -186,16 +184,6 @@ class Storage(_StorageDc):
self.__parts: (dict[str, _Part] | None) = None
@property
- def size(self) -> int: # API Legacy
- assert self.__parts is not None
- return self.__parts[""].size
-
- @property
- def free(self) -> int: # API Legacy
- assert self.__parts is not None
- return self.__parts[""].free
-
- @property
def images(self) -> dict[str, Image]:
assert self.__images is not None
return dict(self.__images)
@@ -222,6 +210,7 @@ class Storage(_StorageDc):
part = _Part(name, root_path)
await part._reload() # pylint: disable=protected-access
parts[name] = part
+ assert "" in parts, parts
self.__watchable_paths = watchable_paths
self.__images = images