From 0ecf8661ebd9d5a8b6ad5e03b043df346c297499 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 10 Dec 2014 18:05:42 +0100 Subject: [PATCH] Create inexistent paths in standardpath.get. See #25. --- qutebrowser/utils/standarddir.py | 35 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index f7b9e42ea..10b857e89 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -86,23 +86,24 @@ def get(typ, args=None): locations. """ overridden, path = _from_args(typ, args) - if overridden: - return path - path = _writable_location(typ) - appname = QCoreApplication.instance().applicationName() - if (typ == QStandardPaths.ConfigLocation and - path.split(os.sep)[-1] != appname): - # WORKAROUND - see - # https://bugreports.qt-project.org/browse/QTBUG-38872 - path = os.path.join(path, appname) - if typ == QStandardPaths.DataLocation and os.name == 'nt': - # Under windows, config/data might end up in the same directory. - data_path = QStandardPaths.writableLocation( - QStandardPaths.DataLocation) - config_path = QStandardPaths.writableLocation( - QStandardPaths.ConfigLocation) - if data_path == config_path: - path = os.path.join(path, 'data') + if not overridden: + path = _writable_location(typ) + appname = QCoreApplication.instance().applicationName() + if (typ == QStandardPaths.ConfigLocation and + path.split(os.sep)[-1] != appname): + # WORKAROUND - see + # https://bugreports.qt-project.org/browse/QTBUG-38872 + path = os.path.join(path, appname) + if typ == QStandardPaths.DataLocation and os.name == 'nt': + # Under windows, config/data might end up in the same directory. + data_path = QStandardPaths.writableLocation( + QStandardPaths.DataLocation) + config_path = QStandardPaths.writableLocation( + QStandardPaths.ConfigLocation) + if data_path == config_path: + path = os.path.join(path, 'data') + if not os.path.exists(path): + os.makedirs(path, 0o700) return path