Skip to content

Commit

Permalink
Merge pull request #2463 from alandtse/dev
Browse files Browse the repository at this point in the history
fix: delete cookiefile when removing config entry (#2462)
  • Loading branch information
alandtse authored Aug 18, 2024
2 parents f7bbe2e + 7b5524c commit cc406d9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime, timedelta
from json import JSONDecodeError, loads
import logging
import os
import time
from typing import Optional

Expand Down Expand Up @@ -1288,6 +1289,7 @@ async def http2_error_handler(message):
async def async_unload_entry(hass, entry) -> bool:
"""Unload a config entry."""
email = entry.data["email"]
login_obj = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"]
_LOGGER.debug("Attempting to unload entry for %s", hide_email(email))
for component in ALEXA_COMPONENTS + DEPENDENT_ALEXA_COMPONENTS:
_LOGGER.debug("Forwarding unload entry to %s", component)
Expand Down Expand Up @@ -1329,6 +1331,15 @@ async def async_unload_entry(hass, entry) -> bool:
_LOGGER.debug("Removing alexa_media data structure")
if hass.data.get(DATA_ALEXAMEDIA):
hass.data.pop(DATA_ALEXAMEDIA)
# Delete cookiefile
try:
await login_obj.delete_cookiefile()
_LOGGER.debug("Deleted cookiefile")
except Exception as ex:
_LOGGER.error(
"Failed to delete cookiefile: %s",
ex,
)
else:
_LOGGER.debug(
"Unable to remove alexa_media data structure: %s",
Expand Down

0 comments on commit cc406d9

Please sign in to comment.