mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-11-25 06:16:18 +03:00
fix: fixed components related error on changing default path
This commit is contained in:
parent
9a0a327bc0
commit
b2ff2c585d
2 changed files with 91 additions and 82 deletions
|
@ -350,6 +350,19 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
if wine.is_downloaded_in(&config.game.wine.builds) {
|
if wine.is_downloaded_in(&config.game.wine.builds) {
|
||||||
tracing::info!("Wine already installed: {}", wine.name);
|
tracing::info!("Wine already installed: {}", wine.name);
|
||||||
|
|
||||||
|
let mut config = config::get().unwrap_or_default();
|
||||||
|
|
||||||
|
config.game.wine.selected = Some(wine.name);
|
||||||
|
|
||||||
|
if let Err(err) = config::update_raw(config) {
|
||||||
|
tracing::error!("Failed to update config: {err}");
|
||||||
|
|
||||||
|
sender.output(Self::Output::Toast {
|
||||||
|
title: tr("config-update-error"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +370,7 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
else {
|
else {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
tracing::info!("Installing wine: {}", wine.name);
|
tracing::info!("Installing wine: {}", wine.name);
|
||||||
|
|
||||||
// Install wine
|
// Install wine
|
||||||
match get_installer(&wine.uri, config.launcher.temp.as_ref(), config.launcher.speed_limit) {
|
match get_installer(&wine.uri, config.launcher.temp.as_ref(), config.launcher.speed_limit) {
|
||||||
Ok(mut installer) => {
|
Ok(mut installer) => {
|
||||||
|
@ -366,53 +379,55 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
std::fs::create_dir_all(&config.game.wine.builds)
|
std::fs::create_dir_all(&config.game.wine.builds)
|
||||||
.expect("Failed to create wine builds directory");
|
.expect("Failed to create wine builds directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
installer.install(&config.game.wine.builds, move |update| {
|
installer.install(&config.game.wine.builds, move |update| {
|
||||||
match &update {
|
match &update {
|
||||||
InstallerUpdate::DownloadingError(err) => {
|
InstallerUpdate::DownloadingError(err) => {
|
||||||
tracing::error!("Failed to download wine: {err}");
|
tracing::error!("Failed to download wine: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("wine-download-error"),
|
title: tr("wine-download-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallerUpdate::UnpackingError(err) => {
|
InstallerUpdate::UnpackingError(err) => {
|
||||||
tracing::error!("Failed to unpack wine: {err}");
|
tracing::error!("Failed to unpack wine: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("wine-unpack-errror"),
|
title: tr("wine-unpack-errror"),
|
||||||
description: Some(err.clone())
|
description: Some(err.clone())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create prefix
|
// Create prefix
|
||||||
InstallerUpdate::UnpackingFinished => {
|
InstallerUpdate::UnpackingFinished => {
|
||||||
let mut config = config::get().unwrap_or_default();
|
let mut config = config::get().unwrap_or_default();
|
||||||
|
|
||||||
config.game.wine.selected = Some(wine.name.clone());
|
config.game.wine.selected = Some(wine.name.clone());
|
||||||
|
|
||||||
if let Err(err) = config::update_raw(config) {
|
if let Err(err) = config::update_raw(config) {
|
||||||
|
tracing::error!("Failed to update config: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("config-update-error"),
|
title: tr("config-update-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
sender.input(DownloadComponentsAppMsg::CreatePrefix);
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_bar_input.send(ProgressBarMsg::UpdateFromState(update));
|
progress_bar_input.send(ProgressBarMsg::UpdateFromState(update));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::error!("Failed to initialize wine installer: {err}");
|
tracing::error!("Failed to initialize wine installer: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("wine-install-failed"),
|
title: tr("wine-install-failed"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
|
@ -477,29 +492,29 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
// Install DXVK
|
// Install DXVK
|
||||||
tracing::info!("Installing DXVK: {}", dxvk.name);
|
tracing::info!("Installing DXVK: {}", dxvk.name);
|
||||||
|
|
||||||
match get_installer(&dxvk.uri, config.launcher.temp.as_ref(), config.launcher.speed_limit) {
|
match get_installer(&dxvk.uri, config.launcher.temp.as_ref(), config.launcher.speed_limit) {
|
||||||
Ok(mut installer) => {
|
Ok(mut installer) => {
|
||||||
let progress_bar_input = progress_bar_input.clone();
|
let progress_bar_input = progress_bar_input.clone();
|
||||||
let sender = sender.clone();
|
let sender = sender.clone();
|
||||||
|
|
||||||
// Create DXVK builds folder
|
// Create DXVK builds folder
|
||||||
if config.game.dxvk.builds.exists() {
|
if config.game.dxvk.builds.exists() {
|
||||||
std::fs::create_dir_all(&config.game.dxvk.builds)
|
std::fs::create_dir_all(&config.game.dxvk.builds)
|
||||||
.expect("Failed to create DXVK builds directory");
|
.expect("Failed to create DXVK builds directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
installer.install(&config.game.dxvk.builds, move |update| {
|
installer.install(&config.game.dxvk.builds, move |update| {
|
||||||
match &update {
|
match &update {
|
||||||
InstallerUpdate::DownloadingError(err) => {
|
InstallerUpdate::DownloadingError(err) => {
|
||||||
tracing::error!("Failed to download dxvk: {err}");
|
tracing::error!("Failed to download dxvk: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("dxvk-download-error"),
|
title: tr("dxvk-download-error"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
InstallerUpdate::UnpackingError(err) => {
|
InstallerUpdate::UnpackingError(err) => {
|
||||||
tracing::error!("Failed to unpack dxvk: {err}");
|
tracing::error!("Failed to unpack dxvk: {err}");
|
||||||
|
|
||||||
|
@ -508,22 +523,22 @@ impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||||
description: Some(err.clone())
|
description: Some(err.clone())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply DXVK
|
// Apply DXVK
|
||||||
InstallerUpdate::UnpackingFinished => {
|
InstallerUpdate::UnpackingFinished => {
|
||||||
sender.input(DownloadComponentsAppMsg::ApplyDXVK);
|
sender.input(DownloadComponentsAppMsg::ApplyDXVK);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
progress_bar_input.send(ProgressBarMsg::UpdateFromState(update));
|
progress_bar_input.send(ProgressBarMsg::UpdateFromState(update));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::error!("Failed to initialize dxvk installer: {err}");
|
tracing::error!("Failed to initialize dxvk installer: {err}");
|
||||||
|
|
||||||
sender.output(Self::Output::Toast {
|
sender.output(Self::Output::Toast {
|
||||||
title: tr("dxvk-install-failed"),
|
title: tr("dxvk-install-failed"),
|
||||||
description: Some(err.to_string())
|
description: Some(err.to_string())
|
||||||
|
|
|
@ -161,7 +161,7 @@ impl SimpleComponent for FirstRunApp {
|
||||||
toast_overlay,
|
toast_overlay,
|
||||||
carousel,
|
carousel,
|
||||||
|
|
||||||
loading: Some(None),
|
loading: None,
|
||||||
title: tr("welcome")
|
title: tr("welcome")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -172,70 +172,16 @@ impl SimpleComponent for FirstRunApp {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
MAIN_WINDOW = Some(widgets.window.clone());
|
MAIN_WINDOW = Some(widgets.window.clone());
|
||||||
|
|
||||||
|
crate::READY = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::info!("First run window initialized");
|
tracing::info!("First run window initialized. App is ready");
|
||||||
|
|
||||||
let components_sender = model.download_components.sender().clone();
|
|
||||||
|
|
||||||
// Initialize some heavy tasks
|
|
||||||
#[allow(unused_must_use)]
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
tracing::info!("Initializing heavy tasks");
|
|
||||||
|
|
||||||
// Update components index
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::SetLoadingStatus(Some(Some(tr("updating-components-index")))));
|
|
||||||
|
|
||||||
let components = ComponentsLoader::new(&CONFIG.components.path);
|
|
||||||
|
|
||||||
match components.is_sync(&CONFIG.components.servers) {
|
|
||||||
Ok(true) => (),
|
|
||||||
|
|
||||||
Ok(false) => {
|
|
||||||
for host in &CONFIG.components.servers {
|
|
||||||
match components.sync(host) {
|
|
||||||
Ok(true) => break,
|
|
||||||
Ok(false) => continue,
|
|
||||||
|
|
||||||
Err(err) => {
|
|
||||||
tracing::error!("Failed to sync components index");
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::Toast {
|
|
||||||
title: tr("components-index-sync-failed"),
|
|
||||||
description: Some(err.to_string())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Err(err) => {
|
|
||||||
tracing::error!("Failed to verify that components index synced");
|
|
||||||
|
|
||||||
sender.input(FirstRunAppMsg::Toast {
|
|
||||||
title: tr("components-index-verify-failed"),
|
|
||||||
description: Some(err.to_string())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update versions lists in download components page and hide status page
|
|
||||||
components_sender.send(DownloadComponentsAppMsg::UpdateVersionsLists);
|
|
||||||
sender.input(FirstRunAppMsg::SetLoadingStatus(None));
|
|
||||||
|
|
||||||
// Mark app as loaded
|
|
||||||
unsafe {
|
|
||||||
crate::READY = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
tracing::info!("App is ready");
|
|
||||||
});
|
|
||||||
|
|
||||||
ComponentParts { model, widgets } // will return soon
|
ComponentParts { model, widgets } // will return soon
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
|
fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>) {
|
||||||
tracing::debug!("Called first run window event: {:?}", msg);
|
tracing::debug!("Called first run window event: {:?}", msg);
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
|
@ -268,6 +214,54 @@ impl SimpleComponent for FirstRunApp {
|
||||||
}
|
}
|
||||||
|
|
||||||
FirstRunAppMsg::ScrollToDownloadComponents => {
|
FirstRunAppMsg::ScrollToDownloadComponents => {
|
||||||
|
// Update components index
|
||||||
|
sender.input(FirstRunAppMsg::SetLoadingStatus(Some(Some(tr("updating-components-index")))));
|
||||||
|
|
||||||
|
let components_sender = self.download_components.sender().clone();
|
||||||
|
let components = ComponentsLoader::new(&CONFIG.components.path);
|
||||||
|
|
||||||
|
#[allow(unused_must_use)]
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
match components.is_sync(&CONFIG.components.servers) {
|
||||||
|
Ok(true) => (),
|
||||||
|
|
||||||
|
Ok(false) => {
|
||||||
|
for host in &CONFIG.components.servers {
|
||||||
|
match components.sync(host) {
|
||||||
|
Ok(true) => break,
|
||||||
|
Ok(false) => continue,
|
||||||
|
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("Failed to sync components index");
|
||||||
|
|
||||||
|
sender.input(FirstRunAppMsg::Toast {
|
||||||
|
title: tr("components-index-sync-failed"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("Failed to verify that components index synced");
|
||||||
|
|
||||||
|
sender.input(FirstRunAppMsg::Toast {
|
||||||
|
title: tr("components-index-verify-failed"),
|
||||||
|
description: Some(err.to_string())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update versions lists in download components page
|
||||||
|
components_sender.send(DownloadComponentsAppMsg::UpdateVersionsLists);
|
||||||
|
|
||||||
|
// Hide status page
|
||||||
|
sender.input(FirstRunAppMsg::SetLoadingStatus(None));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scroll to download components page
|
||||||
|
// This will happen in background behind StatusPage
|
||||||
self.title = tr("download-components");
|
self.title = tr("download-components");
|
||||||
|
|
||||||
self.carousel.scroll_to(self.download_components.widget(), true);
|
self.carousel.scroll_to(self.download_components.widget(), true);
|
||||||
|
|
Loading…
Reference in a new issue