mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix error after losing an imap connection (#90966)
Cleanup first after losing an imap connection
This commit is contained in:
parent
73a960af34
commit
e8a6a2e105
@ -194,7 +194,11 @@ class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
|
|||||||
if count
|
if count
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
if count and last_message_id is not None:
|
if (
|
||||||
|
count
|
||||||
|
and last_message_id is not None
|
||||||
|
and self._last_message_id != last_message_id
|
||||||
|
):
|
||||||
self._last_message_id = last_message_id
|
self._last_message_id = last_message_id
|
||||||
await self._async_process_event(last_message_id)
|
await self._async_process_event(last_message_id)
|
||||||
|
|
||||||
@ -235,18 +239,18 @@ class ImapPollingDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||||||
UpdateFailed,
|
UpdateFailed,
|
||||||
asyncio.TimeoutError,
|
asyncio.TimeoutError,
|
||||||
) as ex:
|
) as ex:
|
||||||
self.async_set_update_error(ex)
|
|
||||||
await self._cleanup()
|
await self._cleanup()
|
||||||
|
self.async_set_update_error(ex)
|
||||||
raise UpdateFailed() from ex
|
raise UpdateFailed() from ex
|
||||||
except InvalidFolder as ex:
|
except InvalidFolder as ex:
|
||||||
_LOGGER.warning("Selected mailbox folder is invalid")
|
_LOGGER.warning("Selected mailbox folder is invalid")
|
||||||
self.async_set_update_error(ex)
|
|
||||||
await self._cleanup()
|
await self._cleanup()
|
||||||
|
self.async_set_update_error(ex)
|
||||||
raise ConfigEntryError("Selected mailbox folder is invalid.") from ex
|
raise ConfigEntryError("Selected mailbox folder is invalid.") from ex
|
||||||
except InvalidAuth as ex:
|
except InvalidAuth as ex:
|
||||||
_LOGGER.warning("Username or password incorrect, starting reauthentication")
|
_LOGGER.warning("Username or password incorrect, starting reauthentication")
|
||||||
self.async_set_update_error(ex)
|
|
||||||
await self._cleanup()
|
await self._cleanup()
|
||||||
|
self.async_set_update_error(ex)
|
||||||
raise ConfigEntryAuthFailed() from ex
|
raise ConfigEntryAuthFailed() from ex
|
||||||
|
|
||||||
|
|
||||||
@ -316,6 +320,7 @@ class ImapPushDataUpdateCoordinator(ImapDataUpdateCoordinator):
|
|||||||
self.config_entry.data[CONF_SERVER],
|
self.config_entry.data[CONF_SERVER],
|
||||||
BACKOFF_TIME,
|
BACKOFF_TIME,
|
||||||
)
|
)
|
||||||
|
await self._cleanup()
|
||||||
await asyncio.sleep(BACKOFF_TIME)
|
await asyncio.sleep(BACKOFF_TIME)
|
||||||
|
|
||||||
async def shutdown(self, *_) -> None:
|
async def shutdown(self, *_) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user