mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-20 12:19:36 +00:00
Fix Kitty crashing on startup when disk is full
This commit is contained in:
parent
c85bcda29c
commit
70d8a536f1
2 changed files with 17 additions and 9 deletions
|
|
@ -463,7 +463,8 @@ class Boss:
|
|||
set_boss(self)
|
||||
self.mappings: Mappings = Mappings(global_shortcuts, self.refresh_active_tab_bar)
|
||||
self.notification_manager: NotificationManager = NotificationManager(debug=self.args.debug_keyboard or self.args.debug_rendering)
|
||||
self.atexit.unlink(store_effective_config())
|
||||
if effective_config_path := store_effective_config():
|
||||
self.atexit.unlink(effective_config_path)
|
||||
|
||||
def startup_first_child(self, os_window_id: int | None, startup_sessions: Iterable[Session] = ()) -> None:
|
||||
si = startup_sessions or create_sessions(get_options(), self.args, default_session=get_options().startup_session)
|
||||
|
|
|
|||
|
|
@ -207,14 +207,21 @@ def store_effective_config() -> str:
|
|||
import stat
|
||||
import tempfile
|
||||
|
||||
dest = os.path.join(cache_dir(), 'effective-config')
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
raw = '\n'.join(effective_config_lines)
|
||||
with suppress(FileNotFoundError), tempfile.NamedTemporaryFile('w', dir=dest) as tf:
|
||||
os.chmod(tf.name, stat.S_IRUSR | stat.S_IWUSR)
|
||||
print(raw, file=tf)
|
||||
path = os.path.join(dest, f'{os.getpid()}')
|
||||
os.replace(tf.name, path)
|
||||
path = ''
|
||||
try:
|
||||
dest = os.path.join(cache_dir(), 'effective-config')
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
raw = '\n'.join(effective_config_lines)
|
||||
with suppress(FileNotFoundError), tempfile.NamedTemporaryFile('w', dir=dest) as tf:
|
||||
os.chmod(tf.name, stat.S_IRUSR | stat.S_IWUSR)
|
||||
print(raw, file=tf)
|
||||
path = os.path.join(dest, f'{os.getpid()}')
|
||||
os.replace(tf.name, path)
|
||||
except OSError as err:
|
||||
# writing the effective config is a best effort debugging aid, do not
|
||||
# let it prevent kitty from starting, for example, when the disk is full
|
||||
log_error(f'Failed to store effective config with error: {err}')
|
||||
path = ''
|
||||
return path
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue