mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-18 23:44:00 +01:00
fix(wm): don't panic if state isn't up to date
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.
This commit is contained in:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user