From: Jakob Date: Sat, 30 Nov 2019 23:44:27 +0000 (-0600) Subject: Fix custom cookie jar bugs X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=e3007c6e2f1bbced178b8e71a543f42b8f9bf692;p=bb-sync-api.git Fix custom cookie jar bugs --- diff --git a/auth.py b/auth.py index c305e43..299dd70 100644 --- a/auth.py +++ b/auth.py @@ -241,16 +241,22 @@ def get_access_token(storage_mgr, api_iface): class StorageMgrCookieJar(http.cookiejar.CookieJar): - def __init__(self, storage_mgr): + def __init__(self, storage_mgr, *args): + super().__init__(*args) self.storage_mgr = storage_mgr def load(self): if 'cookies' not in self.storage_mgr.keys(): - self.storage_mgr['cookies'] = {} - self._cookies = self.storage_mgr['cookies'] + self.storage_mgr['cookies'] = [] + with self._cookies_lock: + self._cookies = {} + for dict_ in self.storage_mgr['cookies']: + self.set_cookie(http.cookiejar.Cookie(**dict_)) def save(self): - self.storage_mgr['cookies'] = self._cookies + lambda fix_dict = lambda d: {k.strip('_'): v for (k, v) in d.items()} + dicts = [fix_dict(c.__dict__) for c in self] + self.storage_mgr['cookies'] = dicts class CookieAuthHandler(urllib.request.HTTPCookieProcessor):