mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-16 16:47:21 +02:00
fix fallback logic
Signed-off-by: Krzysztof Andrelczyk <cristof@curiana.net>
This commit is contained in:
@@ -102,18 +102,15 @@ pub struct RemoteRelease {
|
|||||||
|
|
||||||
impl RemoteRelease {
|
impl RemoteRelease {
|
||||||
/// The release's download URL for the given target.
|
/// The release's download URL for the given target.
|
||||||
pub fn download_url(&self, target: &str, installer: Option<Installer>) -> Result<&Url> {
|
pub fn download_url(&self, fallback_target: &str, installer: Option<Installer>) -> Result<&Url> {
|
||||||
let fallback_target = installer.map(|installer| format!("{target}-{}", installer.suffix()));
|
let target = installer.map(|installer| format!("{fallback_target}-{}", installer.suffix())).unwrap_or("".to_string());
|
||||||
match self.data {
|
match self.data {
|
||||||
RemoteReleaseInner::Dynamic(ref platform) => Ok(&platform.url),
|
RemoteReleaseInner::Dynamic(ref platform) => Ok(&platform.url),
|
||||||
RemoteReleaseInner::Static { ref platforms } => platforms.get(target).map_or_else(
|
RemoteReleaseInner::Static { ref platforms } => platforms.get(&target).map_or_else(
|
||||||
|| match fallback_target {
|
|| platforms.get(fallback_target).map_or(
|
||||||
Some(fallback) => platforms.get(&fallback).map_or(
|
Err(Error::TargetsNotFound(target.to_string(), fallback_target.to_string())),
|
||||||
Err(Error::TargetsNotFound(target.to_string(), fallback)),
|
|
||||||
|p| Ok(&p.url),
|
|p| Ok(&p.url),
|
||||||
),
|
),
|
||||||
None => Err(Error::TargetNotFound(target.to_string())),
|
|
||||||
},
|
|
||||||
|p| Ok(&p.url),
|
|p| Ok(&p.url),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user