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:
parent
bc715d4348
commit
6f0a59c696
@ -7,7 +7,6 @@ import pwd
|
|||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|
||||||
appname = 'kitty'
|
appname = 'kitty'
|
||||||
version = (0, 12, 3)
|
version = (0, 12, 3)
|
||||||
str_version = '.'.join(map(str, version))
|
str_version = '.'.join(map(str, version))
|
||||||
@ -61,6 +60,18 @@ def _get_config_dir():
|
|||||||
os.makedirs(ans, exist_ok=True)
|
os.makedirs(ans, exist_ok=True)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
raise SystemExit('A file {} already exists. It must be a directory, not a file.'.format(ans))
|
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
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user