mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2024-11-25 14:20:08 +03:00
Fixed downloading of fps unlocker and launcher hiding
This commit is contained in:
parent
a7b1345302
commit
41dc6532d8
3 changed files with 21 additions and 7 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
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}"))
|
||||
|
||||
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}"))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Generate FPS unlocker config 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;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue