commit f72a45293f67d6e6b68d1ed5fdc9a427dde24a2f Author: Damian Johnson <ata...@torproject.org> Date: Thu Oct 18 12:12:44 2018 -0700
Notify if nyx cache isn't writable A couple of folks have had Nyx crash due to their cache being unwritable... https://trac.torproject.org/projects/tor/ticket/27938 I suspect this arises when running nyx multiple times as different users that share the same home directory. Rather than crashing, providing a notice and falling back to an in-memory cache. Nyx's startup will be a tad slower when this happens but for most users it probably won't even be noticeable. --- nyx/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nyx/__init__.py b/nyx/__init__.py index 58b3b81..d5585a0 100644 --- a/nyx/__init__.py +++ b/nyx/__init__.py @@ -44,6 +44,7 @@ Tor curses monitoring application. import contextlib import distutils.spawn +import getpass import os import platform import sys @@ -442,10 +443,14 @@ class Cache(object): self._conn_lock = threading.RLock() cache_path = nyx.data_directory('cache.sqlite') + if cache_path and os.path.isfile(cache_path) and not os.access(cache_path, os.W_OK): + stem.util.log.notice("Nyx's cache at %s is not writable by our user (%s). That's ok, but we'll have better performance if we can write to it." % (cache_path, getpass.getuser())) + cache_path = None + if cache_path: try: self._conn = sqlite3.connect(cache_path, check_same_thread = False) - schema = self._conn.execute('SELECT version FROM schema').fetchone()[0] + schema = self._query('SELECT version FROM schema').fetchone()[0] except: schema = None _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits