From fed1566370ba25c059c11d51c4b40c221bcd96ca Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 14 Oct 2014 21:24:09 +0200 Subject: [PATCH] Remove cookies when permissions->cookies-store was changed. Fixes #116. --- qutebrowser/browser/cookies.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/cookies.py b/qutebrowser/browser/cookies.py index 97313f5f9..bb759580f 100644 --- a/qutebrowser/browser/cookies.py +++ b/qutebrowser/browser/cookies.py @@ -39,6 +39,8 @@ class CookieJar(QNetworkCookieJar): for line in self._linecp: cookies += QNetworkCookie.parseCookies(line) self.setAllCookies(cookies) + config.on_change(self.cookies_store_changed, + 'permissions', 'cookies-store') def __repr__(self): return utils.get_repr(self, count=len(self.allCookies())) @@ -70,8 +72,6 @@ class CookieJar(QNetworkCookieJar): def save(self): """Save cookies to disk.""" if not config.get('permissions', 'cookies-store'): - # FIXME if this changed to false we should delete the old cookies - # https://github.com/The-Compiler/qutebrowser/issues/116 return self.purge_old_cookies() lines = [] @@ -80,3 +80,9 @@ class CookieJar(QNetworkCookieJar): lines.append(cookie.toRawForm()) self._linecp.data = lines self._linecp.save() + + def cookies_store_changed(self): + """Delete stored cookies if cookies-store changed.""" + if not config.get('permissions', 'cookies-store'): + self._linecp.data = [] + self._linecp.save()