|
|
|
@ -102,15 +102,26 @@ pub struct RemoteRelease {
|
|
|
|
|
|
|
|
|
|
impl RemoteRelease {
|
|
|
|
|
/// The release's download URL for the given target.
|
|
|
|
|
pub fn download_url(&self, fallback_target: &str, installer: Option<Installer>) -> Result<&Url> {
|
|
|
|
|
let target = installer.map(|installer| format!("{fallback_target}-{}", installer.suffix())).unwrap_or("".to_string());
|
|
|
|
|
pub fn download_url(
|
|
|
|
|
&self,
|
|
|
|
|
fallback_target: &str,
|
|
|
|
|
installer: Option<Installer>,
|
|
|
|
|
) -> 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(
|
|
|
|
|
|| platforms.get(fallback_target).map_or(
|
|
|
|
|
Err(Error::TargetsNotFound(target.to_string(), fallback_target.to_string())),
|
|
|
|
|
|| {
|
|
|
|
|
platforms.get(fallback_target).map_or(
|
|
|
|
|
Err(Error::TargetsNotFound(
|
|
|
|
|
target.to_string(),
|
|
|
|
|
fallback_target.to_string(),
|
|
|
|
|
)),
|
|
|
|
|
|p| Ok(&p.url),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|p| Ok(&p.url),
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|