Fixed downloading of fps unlocker and launcher hiding

This commit is contained in:
Observer KRypt0n_ 2022-09-12 00:00:17 +02:00
parent a7b1345302
commit 41dc6532d8
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
3 changed files with 21 additions and 7 deletions

View file

@ -48,7 +48,11 @@ impl FpsUnlocker {
}
pub fn get_binary(&self) -> String {
format!("{}/unlocker.exe", self.dir)
Self::get_binary_in(&self.dir)
}
pub fn get_binary_in<T: ToString>(dir: T) -> String {
format!("{}/unlocker.exe", dir.to_string())
}
pub fn dir(&self) -> &str {

View file

@ -90,11 +90,19 @@ pub fn run() -> anyhow::Result<()> {
if config.game.enhancements.fps_unlocker.enabled {
let unlocker = match FpsUnlocker::from_dir(&config.game.enhancements.fps_unlocker.path) {
Ok(Some(unlocker)) => unlocker,
Ok(None) => match FpsUnlocker::download(&config.game.enhancements.fps_unlocker.path) {
other => {
// Ok(None) means unknown version, so we should delete it before downloading newer one
// because otherwise downloader will try to continue downloading "partially downloaded" file
if let Ok(None) = other {
std::fs::remove_file(FpsUnlocker::get_binary_in(&config.game.enhancements.fps_unlocker.path))?;
}
match FpsUnlocker::download(&config.game.enhancements.fps_unlocker.path) {
Ok(unlocker) => unlocker,
Err(err) => return Err(anyhow::anyhow!("Failed to download FPS unlocker: {err}"))
},
Err(err) => return Err(anyhow::anyhow!("Failed to load FPS unlocker: {err}"))
}
}
};
// Generate FPS unlocker config file

View file

@ -334,7 +334,9 @@ impl App {
match Command::new("ps").arg("-A").stdout(Stdio::piped()).output() {
Ok(output) => {
if !String::from_utf8_lossy(&output.stdout).contains("GenshinImpact.e") {
let output = String::from_utf8_lossy(&output.stdout);
if !output.contains("GenshinImpact.e") && !output.contains("unlocker.exe") {
break;
}
},