Skip to content

Commit

Permalink
fix(wm): don't panic if state isn't up to date
Browse files Browse the repository at this point in the history
This commit makes sure that if the state on file isn't up to date with
the expected `State` struct (maybe after an update) it doesn't panic
komorebi entirely, instead it ignores the state and continues with a
clean state.
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Feb 21, 2025
1 parent c62405b commit ec8519d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions komorebi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,14 @@ fn main() -> Result<()> {
let dumped_state = temp_dir().join("komorebi.state.json");

if !opts.clean_state && dumped_state.is_file() {
let state: State = serde_json::from_str(&std::fs::read_to_string(&dumped_state)?)?;
wm.lock().apply_state(state);
if let Ok(state) = serde_json::from_str(&std::fs::read_to_string(&dumped_state)?) {
wm.lock().apply_state(state);
} else {
tracing::warn!(
"cannot apply state from {}; state struct is not up to date",
dumped_state.display()
);
}
}

wm.lock().retile_all(false)?;
Expand Down

0 comments on commit ec8519d

Please sign in to comment.