Skip to content

Commit 9e9d7bc

Browse files
committed
fix fallback logic
Signed-off-by: Krzysztof Andrelczyk <[email protected]>
1 parent 513376b commit 9e9d7bc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

plugins/updater/src/updater.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,15 @@ pub struct RemoteRelease {
102102

103103
impl RemoteRelease {
104104
/// The release's download URL for the given target.
105-
pub fn download_url(&self, target: &str, installer: Option<Installer>) -> Result<&Url> {
106-
let fallback_target = installer.map(|installer| format!("{target}-{}", installer.suffix()));
105+
pub fn download_url(&self, fallback_target: &str, installer: Option<Installer>) -> Result<&Url> {
106+
let target = installer.map(|installer| format!("{fallback_target}-{}", installer.suffix())).unwrap_or("".to_string());
107107
match self.data {
108108
RemoteReleaseInner::Dynamic(ref platform) => Ok(&platform.url),
109-
RemoteReleaseInner::Static { ref platforms } => platforms.get(target).map_or_else(
110-
|| match fallback_target {
111-
Some(fallback) => platforms.get(&fallback).map_or(
112-
Err(Error::TargetsNotFound(target.to_string(), fallback)),
109+
RemoteReleaseInner::Static { ref platforms } => platforms.get(&target).map_or_else(
110+
|| platforms.get(fallback_target).map_or(
111+
Err(Error::TargetsNotFound(target.to_string(), fallback_target.to_string())),
113112
|p| Ok(&p.url),
114113
),
115-
None => Err(Error::TargetNotFound(target.to_string())),
116-
},
117114
|p| Ok(&p.url),
118115
),
119116
}

0 commit comments

Comments
 (0)