fix: fixed repair button functionality

Resolves #186
This commit is contained in:
Observer KRypt0n_ 2023-06-08 10:22:36 +02:00
parent 1c5957910e
commit cb529f10d0
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -105,11 +105,45 @@ pub fn repair_game(sender: ComponentSender<App>, progress_bar_input: Sender<Prog
let total = broken.len() as f64; let total = broken.len() as f64;
let player_patch = UnityPlayerPatch::from_folder(&config.patch.path, config.launcher.edition).unwrap() // Get main patch status
.is_applied(&game_path).unwrap();
let xlua_patch = XluaPatch::from_folder(&config.patch.path, config.launcher.edition).unwrap() let player_patch = UnityPlayerPatch::from_folder(&config.patch.path, config.launcher.edition)
.is_applied(&game_path).unwrap(); .and_then(|patch| patch.is_applied(&game_path));
let player_patch = match player_patch {
Ok(patch) => patch,
Err(err) => {
// TODO: do we really need this toast message here? Perhaps it's not an error but a warning?
sender.input(AppMsg::Toast {
title: tr("patch-info-fetching-error"),
description: Some(err.to_string())
});
tracing::error!("Failed to get player patch status: {err}. Used config value instead: {}", config.patch.apply_main);
config.patch.apply_main
}
};
// Get xlua patch status
let xlua_patch = XluaPatch::from_folder(&config.patch.path, config.launcher.edition)
.and_then(|patch| patch.is_applied(&game_path));
let xlua_patch = match xlua_patch {
Ok(patch) => patch,
Err(err) => {
// TODO: do we really need this toast message here? Perhaps it's not an error but a warning?
sender.input(AppMsg::Toast {
title: tr("patch-info-fetching-error"),
description: Some(err.to_string())
});
tracing::error!("Failed to get xlua patch status: {err}. Used config value instead: {}", config.patch.apply_xlua);
config.patch.apply_xlua
}
};
tracing::debug!("Patches status: player({player_patch}), xlua({xlua_patch})"); tracing::debug!("Patches status: player({player_patch}), xlua({xlua_patch})");