From 3d5599facb85a0ebebc3f69eefe804fce34f413b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 22 Aug 2015 22:53:03 +0200 Subject: [PATCH] Move session dir handling out of SessionManager. --- qutebrowser/misc/sessions.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 89fba7bcd..75955d8c9 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -47,7 +47,15 @@ def init(parent=None): Args: parent: The parent to use for the SessionManager. """ - session_manager = SessionManager(parent) + data_dir = standarddir.data() + if data_dir is None: + base_path = None + else: + base_path = os.path.join(standarddir.data(), 'sessions') + if not os.path.exists(base_path): + os.mkdir(base_path) + + session_manager = SessionManager(base_path, parent) objreg.register('session-manager', session_manager) @@ -79,18 +87,12 @@ class SessionManager(QObject): update_completion = pyqtSignal() - def __init__(self, parent=None): + def __init__(self, base_path, parent=None): super().__init__(parent) self._current = None - data_dir = standarddir.data() - if data_dir is None: - self._base_path = None - else: - self._base_path = os.path.join(standarddir.data(), 'sessions') + self._base_path = base_path self._last_window_session = None self.did_load = False - if self._base_path is not None and not os.path.exists(self._base_path): - os.mkdir(self._base_path) def _get_session_path(self, name, check_exists=False): """Get the session path based on a session name or absolute path.