From b7ca18495ef93a87a314ca40409053ec77ccaff1 Mon Sep 17 00:00:00 2001 From: Nikita Podvirnyi Date: Fri, 19 Jul 2024 12:39:27 +0200 Subject: [PATCH] feat: changed background images processing logic --- src/background.rs | 14 ++++---------- src/main.rs | 6 +++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/background.rs b/src/background.rs index bcef26f..288f804 100644 --- a/src/background.rs +++ b/src/background.rs @@ -73,12 +73,6 @@ pub fn download_background() -> anyhow::Result<()> { tracing::debug!("Background picture is already downloaded. Skipping"); download_image = false; - - if crate::BACKGROUND_PRIMARY_FILE.exists() { - tracing::debug!("Background picture is already patched. Skipping"); - - return Ok(()); - } } } @@ -97,20 +91,20 @@ pub fn download_background() -> anyhow::Result<()> { Command::new("dwebp") .arg(crate::BACKGROUND_FILE.as_path()) .arg("-o") - .arg(crate::BACKGROUND_PRIMARY_FILE.as_path()) + .arg(crate::PROCESSED_BACKGROUND_FILE.as_path()) .spawn()? .wait()?; // If it failed to re-code the file - just copy it // Will happen with HSR because devs apparently named // their background image ".webp" while it's JPEG - if !crate::BACKGROUND_PRIMARY_FILE.exists() { - std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::BACKGROUND_PRIMARY_FILE.as_path())?; + if !crate::PROCESSED_BACKGROUND_FILE.exists() { + std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::PROCESSED_BACKGROUND_FILE.as_path())?; } } else { - std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::BACKGROUND_PRIMARY_FILE.as_path())?; + std::fs::copy(crate::BACKGROUND_FILE.as_path(), crate::PROCESSED_BACKGROUND_FILE.as_path())?; } Ok(()) diff --git a/src/main.rs b/src/main.rs index 868d7e8..c0ddcf2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,8 +61,8 @@ lazy_static::lazy_static! { /// Path to `background` file. Standard is `$HOME/.local/share/anime-game-launcher/background` pub static ref BACKGROUND_FILE: PathBuf = LAUNCHER_FOLDER.join("background"); - /// Path to `background-primary` file. Standard is `$HOME/.local/share/anime-game-launcher/background-primary` - pub static ref BACKGROUND_PRIMARY_FILE: PathBuf = LAUNCHER_FOLDER.join("background-primary"); + /// Path to the processed `background` file. Standard is `$HOME/.cache/anime-game-launcher/background` + pub static ref PROCESSED_BACKGROUND_FILE: PathBuf = CACHE_FOLDER.join("background"); /// Path to `.keep-background` file. Used to mark launcher that it shouldn't update background picture /// @@ -102,7 +102,7 @@ lazy_static::lazy_static! { .round-bin {{ border-radius: 24px; }} - ", BACKGROUND_PRIMARY_FILE.to_string_lossy()); + ", PROCESSED_BACKGROUND_FILE.to_string_lossy()); } fn main() -> anyhow::Result<()> {