From 9e9d7bc15edd99759c8fcd2b2953afbcc861c8b1 Mon Sep 17 00:00:00 2001 From: Krzysztof Andrelczyk Date: Thu, 10 Jul 2025 00:46:50 +0200 Subject: [PATCH] fix fallback logic Signed-off-by: Krzysztof Andrelczyk --- plugins/updater/src/updater.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/updater/src/updater.rs b/plugins/updater/src/updater.rs index 12a305b2..8ffb5e28 100644 --- a/plugins/updater/src/updater.rs +++ b/plugins/updater/src/updater.rs @@ -102,18 +102,15 @@ pub struct RemoteRelease { impl RemoteRelease { /// The release's download URL for the given target. - pub fn download_url(&self, target: &str, installer: Option) -> Result<&Url> { - let fallback_target = installer.map(|installer| format!("{target}-{}", installer.suffix())); + pub fn download_url(&self, fallback_target: &str, installer: Option) -> Result<&Url> { + let target = installer.map(|installer| format!("{fallback_target}-{}", installer.suffix())).unwrap_or("".to_string()); match self.data { RemoteReleaseInner::Dynamic(ref platform) => Ok(&platform.url), - RemoteReleaseInner::Static { ref platforms } => platforms.get(target).map_or_else( - || match fallback_target { - Some(fallback) => platforms.get(&fallback).map_or( - Err(Error::TargetsNotFound(target.to_string(), fallback)), + RemoteReleaseInner::Static { ref platforms } => platforms.get(&target).map_or_else( + || platforms.get(fallback_target).map_or( + Err(Error::TargetsNotFound(target.to_string(), fallback_target.to_string())), |p| Ok(&p.url), ), - None => Err(Error::TargetNotFound(target.to_string())), - }, |p| Ok(&p.url), ), }