If a permission error occurs creating the kitty config directory use a temp dir as the config directory. Fixes #1152

This commit is contained in:
Kovid Goyal 2018-11-18 20:02:55 +05:30
parent bc715d4348
commit 6f0a59c696
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,7 +7,6 @@ import pwd
import sys
from collections import namedtuple
appname = 'kitty'
version = (0, 12, 3)
str_version = '.'.join(map(str, version))
@ -61,6 +60,18 @@ def _get_config_dir():
os.makedirs(ans, exist_ok=True)
except FileExistsError:
raise SystemExit('A file {} already exists. It must be a directory, not a file.'.format(ans))
except PermissionError:
import tempfile
import atexit
ans = tempfile.mkdtemp(prefix='kitty-conf-')
def cleanup():
import shutil
try:
shutil.rmtree(ans)
except Exception:
pass
atexit.register(cleanup)
return ans