mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-06-18 16:06:30 +00:00
Fix ingress session cleanup (#4719)
This commit is contained in:
parent
043111b91c
commit
c74f87ca12
@ -88,7 +88,7 @@ class Ingress(FileConfiguration, CoreSysAttributes):
|
||||
now = utcnow()
|
||||
|
||||
sessions = {}
|
||||
sessions_data: dict[str, IngressSessionData] = {}
|
||||
sessions_data: dict[str, dict[str, str | None]] = {}
|
||||
for session, valid in self.sessions.items():
|
||||
# check if timestamp valid, to avoid crash on malformed timestamp
|
||||
try:
|
||||
@ -102,7 +102,8 @@ class Ingress(FileConfiguration, CoreSysAttributes):
|
||||
|
||||
# Is valid
|
||||
sessions[session] = valid
|
||||
sessions_data[session] = self.sessions_data.get(session)
|
||||
if session_data := self.sessions_data.get(session):
|
||||
sessions_data[session] = session_data
|
||||
|
||||
# Write back
|
||||
self.sessions.clear()
|
||||
|
@ -88,3 +88,14 @@ async def test_ingress_save_data(coresys: CoreSys, tmp_supervisor_data: Path):
|
||||
},
|
||||
"ports": {},
|
||||
}
|
||||
|
||||
|
||||
async def test_ingress_reload_ignore_none_data(coresys: CoreSys):
|
||||
"""Test reloading ingress does not add None for session data and create errors."""
|
||||
session = coresys.ingress.create_session()
|
||||
assert session in coresys.ingress.sessions
|
||||
assert session not in coresys.ingress.sessions_data
|
||||
|
||||
await coresys.ingress.reload()
|
||||
assert session in coresys.ingress.sessions
|
||||
assert session not in coresys.ingress.sessions_data
|
||||
|
Loading…
x
Reference in New Issue
Block a user