Skip to content

Commit

Permalink
fix: optimize IS_LINUX check in restore_discoveries (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Dec 5, 2022
1 parent 5596cfe commit f22eb33
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/bleak_retry_connector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,10 +739,12 @@ async def _async_wrap_bluetooth_connection_error_retry(


async def restore_discoveries(scanner: BleakScanner, adapter: str) -> None:
"""Restore discoveries from the storage."""
"""Restore discoveries from the bus."""
if not IS_LINUX:
# This is only supported on Linux
return
if not (properties := await _get_properties()):
if IS_LINUX:
_LOGGER.debug("Failed to restore discoveries for %s", adapter)
_LOGGER.debug("Failed to restore discoveries for %s", adapter)
return
backend = scanner._backend
before = len(backend.seen_devices)
Expand All @@ -754,4 +756,6 @@ async def restore_discoveries(scanner: BleakScanner, adapter: str) -> None:
).items()
}
)
_LOGGER.debug("Restored %s discoveries", len(backend.seen_devices) - before)
_LOGGER.debug(
"Restored %s discoveries for %s", len(backend.seen_devices) - before, adapter
)

0 comments on commit f22eb33

Please sign in to comment.