From 3bdfa3001c1c95cab1e9294a1bc1ff9be1530d9f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 11 Sep 2015 21:13:37 +0200 Subject: [PATCH] ipc: Always use standarddir.runtime(). --- qutebrowser/misc/ipc.py | 6 +----- qutebrowser/utils/standarddir.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index de0919d16..c8decd89d 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -63,11 +63,7 @@ def _get_socketname(basedir, legacy=False): data_to_hash = '-'.join(parts_to_hash).encode('utf-8') md5 = hashlib.md5(data_to_hash).hexdigest() - if sys.platform.startswith('linux'): - target_dir = standarddir.runtime() - else: # pragma: no cover - # OS X or other Unix - target_dir = standarddir.temp() + target_dir = standarddir.runtime() parts = ['ipc'] parts.append(md5) diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index ce2830d52..8ac1b87cc 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -20,6 +20,7 @@ """Utilities to get and initialize data/config paths.""" import os +import sys import os.path from PyQt5.QtCore import QCoreApplication, QStandardPaths @@ -86,11 +87,22 @@ def download(): def runtime(): """Get a location for runtime data.""" - typ = QStandardPaths.RuntimeLocation + if sys.platform.startswith('linux'): + typ = QStandardPaths.RuntimeLocation + else: # pragma: no cover + # RuntimeLocation is a weird path on OS X and Windows. + typ = QStandardPaths.TempLocation overridden, path = _from_args(typ, _args) if not overridden: path = _writable_location(typ) # This is generic, but per-user. + # + # For TempLocation: + # "The returned value might be application-specific, shared among + # other applications for this user, or even system-wide." + # + # Unfortunately this path could get too long for sockets (which have a + # maximum length of 104 chars), so we don't add the username here... appname = QCoreApplication.instance().applicationName() path = os.path.join(path, appname) _maybe_create(path)