diff options
author | Daniel Schadt <kingdread@gmx.de> | 2016-04-26 23:14:55 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2016-04-30 14:42:52 +0200 |
commit | 36d2fc4b92b3f8a4541b95df80386e70540d690e (patch) | |
tree | 220bd43443e0214f2f24669e0d5e13f6a9b3ffe2 | |
parent | 26f4acb10adee7c63f7e41fa9fe573a2b35acf39 (diff) | |
download | qutebrowser-36d2fc4b92b3f8a4541b95df80386e70540d690e.tar.gz qutebrowser-36d2fc4b92b3f8a4541b95df80386e70540d690e.zip |
cache: fix crash when cache_dir is None
Issue #1412
When passing --cachedir="" on the command line, standarddir.cache()
returns None, which stands for "deactivate cache" and has to be
properly handled in DiskCache.__init__() (i.e. don't pass it to
os.path.join)
-rw-r--r-- | qutebrowser/browser/cache.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/qutebrowser/browser/cache.py b/qutebrowser/browser/cache.py index b34fa232b..5ef53837a 100644 --- a/qutebrowser/browser/cache.py +++ b/qutebrowser/browser/cache.py @@ -32,16 +32,23 @@ class DiskCache(QNetworkDiskCache): """Disk cache which sets correct cache dir and size. + If the cache is deactivated via the command line argument --cachedir="", + both attributes _cache_dir and _http_cache_dir are set to None. + Attributes: _activated: Whether the cache should be used. - _cache_dir: The base directory for cache files (standarddir.cache()) - _http_cache_dir: the HTTP subfolder in _cache_dir. + _cache_dir: The base directory for cache files (standarddir.cache()) or + None. + _http_cache_dir: the HTTP subfolder in _cache_dir or None. """ def __init__(self, cache_dir, parent=None): super().__init__(parent) self._cache_dir = cache_dir - self._http_cache_dir = os.path.join(cache_dir, 'http') + if cache_dir is None: + self._http_cache_dir = None + else: + self._http_cache_dir = os.path.join(cache_dir, 'http') self._maybe_activate() objreg.get('config').changed.connect(self.on_config_changed) |