diff --git a/doc/qutebrowser.1.asciidoc b/doc/qutebrowser.1.asciidoc index dd7857c80..2a403de5f 100644 --- a/doc/qutebrowser.1.asciidoc +++ b/doc/qutebrowser.1.asciidoc @@ -96,6 +96,9 @@ show it. *--pdb-postmortem*:: Drop into pdb on exceptions. +*--temp-basedir*:: + Use a temporary basedir. + *--qt-name* 'NAME':: Set the window name. diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 2928b3bf8..02f8af907 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -26,6 +26,8 @@ import configparser import functools import json import time +import shutil +import tempfile from PyQt5.QtWidgets import QApplication, QMessageBox from PyQt5.QtGui import QDesktopServices, QPixmap, QIcon, QCursor, QWindow @@ -66,6 +68,9 @@ def run(args): print(version.GPL_BOILERPLATE.strip()) sys.exit(0) + if args.temp_basedir: + args.basedir = tempfile.mkdtemp() + quitter = Quitter(args) objreg.register('quitter', quitter) @@ -638,6 +643,9 @@ class Quitter: # Re-enable faulthandler to stdout, then remove crash log log.destroy.debug("Deactivating crash log...") objreg.get('crash-handler').destroy_crashlogfile() + # Delete temp basedir + if self._args.temp_basedir: + shutil.rmtree(self._args.basedir) # If we don't kill our custom handler here we might get segfaults log.destroy.debug("Deactiving message handler...") qInstallMessageHandler(None) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 21604c406..03f3c582b 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -94,6 +94,8 @@ def get_argparser(): "show a crash dialog.") debug.add_argument('--pdb-postmortem', action='store_true', help="Drop into pdb on exceptions.") + debug.add_argument('--temp-basedir', action='store_true', help="Use a " + "temporary basedir.") # For the Qt args, we use store_const with const=True rather than # store_true because we want the default to be None, to make # utils.qt:get_args easier.