Skip to content

Commit

Permalink
autopilot_manager: Add cache versions/download url
Browse files Browse the repository at this point in the history
* Add cache in get_available_versions and get_download_url to reduce
  time in repeated calls since these operations can be slow
  • Loading branch information
JoaoMario109 committed May 24, 2024
1 parent 48c9637 commit 49be9fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/services/ardupilot_manager/firmware/FirmwareDownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from urllib.parse import urlparse
from urllib.request import urlopen, urlretrieve

from commonwealth.utils.decorators import temporary_cache
from loguru import logger
from packaging.version import Version

Expand Down Expand Up @@ -130,6 +131,7 @@ def _find_version_item(self, **args: str) -> List[Dict[str, Any]]:

return found_version_item

@temporary_cache(timeout_seconds=3600)
def get_available_versions(self, vehicle: Vehicle, platform: Platform) -> List[str]:
"""Get available firmware versions for the specific plataform and vehicle
Expand All @@ -153,6 +155,7 @@ def get_available_versions(self, vehicle: Vehicle, platform: Platform) -> List[s

return available_versions

@temporary_cache(timeout_seconds=3600)
def get_download_url(self, vehicle: Vehicle, platform: Platform, version: str = "") -> str:
"""Find a specific firmware URL from manifest that matches the arguments.
Expand Down

0 comments on commit 49be9fd

Please sign in to comment.