fix: (potentially) fixed a bug with pre-download button

This commit is contained in:
Nikita Podvirnyi 2024-08-29 18:05:48 +02:00
parent c6eb063973
commit dd85f1b6d3
No known key found for this signature in database
GPG key ID: 859D416E5142AFF3
2 changed files with 16 additions and 14 deletions

6
Cargo.lock generated
View file

@ -57,7 +57,8 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
[[package]] [[package]]
name = "anime-game-core" name = "anime-game-core"
version = "1.22.2" version = "1.23.0"
source = "git+https://github.com/an-anime-team/anime-game-core?tag=1.23.0#9db1b598418c8c973b4e3afbdc17dcacc8511f3f"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bzip2", "bzip2",
@ -106,7 +107,8 @@ dependencies = [
[[package]] [[package]]
name = "anime-launcher-sdk" name = "anime-launcher-sdk"
version = "1.18.0" version = "1.19.0"
source = "git+https://github.com/an-anime-team/anime-launcher-sdk?tag=1.19.0#18bbd738c9e941b76c1883a969cf9de87e724646"
dependencies = [ dependencies = [
"anime-game-core", "anime-game-core",
"anyhow", "anyhow",

View file

@ -330,16 +330,16 @@ impl SimpleComponent for App {
let temp = config.launcher.temp.unwrap_or_else(std::env::temp_dir); let temp = config.launcher.temp.unwrap_or_else(std::env::temp_dir);
let mut downloaded = temp.join(game.file_name().unwrap()).metadata() let mut downloaded = temp.join(game.file_name().unwrap()).metadata()
.map(|metadata| Some(metadata.len()) == game.downloaded_size()) .map(|metadata| Some(metadata.len()) >= game.downloaded_size())
.unwrap_or(false); .unwrap_or(false);
if downloaded { if downloaded {
for voice in voices { for voice in voices {
downloaded = !temp.join(voice.file_name().unwrap()).metadata() downloaded = temp.join(voice.file_name().unwrap()).metadata()
.map(|metadata| Some(metadata.len()) == voice.downloaded_size()) .map(|metadata| Some(metadata.len()) >= voice.downloaded_size())
.unwrap_or(false); .unwrap_or(false);
if downloaded { if !downloaded {
break; break;
} }
} }
@ -358,16 +358,16 @@ impl SimpleComponent for App {
let temp = config.launcher.temp.unwrap_or_else(std::env::temp_dir); let temp = config.launcher.temp.unwrap_or_else(std::env::temp_dir);
let mut downloaded = temp.join(game.file_name().unwrap()).metadata() let mut downloaded = temp.join(game.file_name().unwrap()).metadata()
.map(|metadata| Some(metadata.len()) == game.downloaded_size()) .map(|metadata| Some(metadata.len()) >= game.downloaded_size())
.unwrap_or(false); .unwrap_or(false);
if downloaded { if downloaded {
for voice in voices { for voice in voices {
downloaded = !temp.join(voice.file_name().unwrap()).metadata() downloaded = temp.join(voice.file_name().unwrap()).metadata()
.map(|metadata| Some(metadata.len()) == voice.downloaded_size()) .map(|metadata| Some(metadata.len()) >= voice.downloaded_size())
.unwrap_or(false); .unwrap_or(false);
if downloaded { if !downloaded {
break; break;
} }
} }
@ -541,11 +541,11 @@ impl SimpleComponent for App {
} }
// Old warning message which I don't really understand now: // Old warning message which I don't really understand now:
// //
// Doesn't work on all the systems // Doesn't work on all the systems
// e.g. won't work if you didn't install wine system-wide // e.g. won't work if you didn't install wine system-wide
// there's some reasons for it // there's some reasons for it
// //
// UPD: I've tried this, and the problem is that it's completely pointless // UPD: I've tried this, and the problem is that it's completely pointless
// For whatever reason it just doesn't work // For whatever reason it just doesn't work
@ -1015,7 +1015,7 @@ impl SimpleComponent for App {
tracing::error!("Failed to update launcher state: {err}"); tracing::error!("Failed to update launcher state: {err}");
self.toast(tr!("launcher-state-updating-error"), Some(err.to_string())); self.toast(tr!("launcher-state-updating-error"), Some(err.to_string()));
None None
} }
}; };
@ -1027,7 +1027,7 @@ impl SimpleComponent for App {
} else { } else {
self.disabled_buttons = false; self.disabled_buttons = false;
} }
if let Some(state) = state { if let Some(state) = state {
match state { match state {
LauncherState::GameUpdateAvailable(_) | LauncherState::GameUpdateAvailable(_) |