Skip to content

Commit

Permalink
Gather update methods to try to update faster (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Apr 12, 2024
1 parent 2f7df3b commit fe52858
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/synology_dsm/synology_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import socket
from ipaddress import IPv6Address
from json import JSONDecodeError
from typing import Any, TypedDict
from typing import Any, Coroutine, TypedDict
from urllib.parse import quote, urlencode

import aiohttp
Expand Down Expand Up @@ -398,38 +398,42 @@ async def update(
self, with_information: bool = False, with_network: bool = False
) -> None:
"""Updates the various instanced modules."""
update_methods: list[Coroutine[Any, Any, None]] = []

if self._download:
await self._download.update()
update_methods.append(self._download.update())

if self._external_usb:
await self._external_usb.update()
update_methods.append(self._external_usb.update())

if self._information and with_information:
await self._information.update()
update_methods.append(self._information.update())

if self._network and with_network:
await self._network.update()
update_methods.append(self._network.update())

if self._security:
await self._security.update()
update_methods.append(self._security.update())

if self._utilisation:
await self._utilisation.update()
update_methods.append(self._utilisation.update())

if self._storage:
await self._storage.update()
update_methods.append(self._storage.update())

if self._share:
await self._share.update()
update_methods.append(self._share.update())

if self._surveillance:
await self._surveillance.update()
update_methods.append(self._surveillance.update())

if self._system:
await self._system.update()
update_methods.append(self._system.update())

if self._upgrade:
await self._upgrade.update()
update_methods.append(self._upgrade.update())

await asyncio.gather(*update_methods)

def reset(self, api: SynoBaseApi | str) -> bool:
"""Reset an API to avoid fetching in on update."""
Expand Down

0 comments on commit fe52858

Please sign in to comment.