mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-05-31 01:19:36 +00:00
Reduce cookies file size by removing empty cookie entries
This commit is contained in:
@@ -489,6 +489,12 @@ class Twitch:
|
||||
await self.websocket.stop(clear_topics=True)
|
||||
if self._session is not None:
|
||||
cookie_jar = cast(aiohttp.CookieJar, self._session.cookie_jar)
|
||||
# clear empty cookie entries off the cookies file before saving
|
||||
# NOTE: Unfortunately, aiohttp provides no easy way of clearing empty cookies,
|
||||
# so we need to access the private '_cookies' attribute for this.
|
||||
for cookie_key, cookie in list(cookie_jar._cookies.items()):
|
||||
if not cookie:
|
||||
del cookie_jar._cookies[cookie_key]
|
||||
cookie_jar.save(COOKIES_PATH)
|
||||
await self._session.close()
|
||||
self._session = None
|
||||
|
||||
Reference in New Issue
Block a user