From b43b689955bc93f5ea58b6f758e7f3bd38f49e65 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 18 Jun 2023 10:49:29 +0200 Subject: [PATCH] feat(core): added discord rpc icons updating --- src/ui/preferences/enhancements/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ui/preferences/enhancements/mod.rs b/src/ui/preferences/enhancements/mod.rs index d55dccf..f4516e6 100644 --- a/src/ui/preferences/enhancements/mod.rs +++ b/src/ui/preferences/enhancements/mod.rs @@ -670,9 +670,24 @@ impl SimpleAsyncComponent for EnhancementsApp { match DiscordRpc::get_assets(CONFIG.launcher.discord_rpc.app_id) { Ok(icons) => { for icon in icons { - let cache_file = CACHE_FOLDER.join("discord-rpc").join(&icon.name); + let cache_file = CACHE_FOLDER + .join("discord-rpc") + .join(&icon.name) + .join(&icon.id); + // let sender = sender.clone(); + // Workaround for old folder structure (pre 3.7.3) + let old_path = CACHE_FOLDER.join("discord-rpc").join(&icon.name); + + if old_path.exists() { + if let Ok(metadata) = old_path.metadata() { + if metadata.is_file() { + std::fs::remove_file(old_path).expect("Failed to delete old discord rpc icon"); + } + } + } + if !cache_file.exists() { std::thread::spawn(move || { Downloader::new(icon.get_uri())