Skip to content

Commit 6c2f563

Browse files
committed
fix fallback logic
1 parent 5b4c1c1 commit 6c2f563

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

plugins/updater/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub enum Error {
4343
#[error("the platform `{0}` was not found in the response `platforms` object")]
4444
TargetNotFound(String),
4545
/// Neither the platform not the fallback platform was not found in the updater JSON response.
46-
#[error("the platform `{0}` and `{1}` were not found in the response `platforms` object")]
46+
#[error("neither platform `{0}` nor`{1}` were found in the response `platforms` object")]
4747
TargetsNotFound(String, String),
4848
/// Download failed
4949
#[error("`{0}`")]

plugins/updater/src/updater.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -514,25 +514,34 @@ impl Updater {
514514
let mut signature = release.signature(&self.json_target);
515515

516516
let installer = self.get_updater_installer();
517-
if installer.is_none() && (download_url.is_err() || signature.is_err()) {
518-
return Err(Error::TargetNotFound(self.json_target.clone()));
519-
}
520517

521518
if let Some(installer) = installer {
522519
let target = &format!("{}-{}", &self.json_target, installer.suffix());
523-
download_url =
524-
release
525-
.download_url(target)
526-
.or(download_url.or(Err(Error::TargetsNotFound(
520+
log::debug!(
521+
"Bundle type is {}. Checking for plattform {target} in response",
522+
installer.suffix()
523+
);
524+
let bundle_url = release.download_url(target);
525+
let bundle_signature = release.signature(target);
526+
if bundle_url.is_err() || bundle_signature.is_err() {
527+
if download_url.is_err() || signature.is_err() {
528+
return Err(Error::TargetsNotFound(
527529
self.json_target.clone(),
528530
target.clone(),
529-
))));
530-
signature = release
531-
.signature(target)
532-
.or(signature.or(Err(Error::TargetsNotFound(
533-
self.json_target.clone(),
534-
target.clone(),
535-
))));
531+
));
532+
}
533+
log::debug!("Plattform {target} not found in response. Using fallback URL");
534+
} else {
535+
log::debug!("Plattform {target} found in response");
536+
download_url = bundle_url;
537+
signature = bundle_signature;
538+
}
539+
} else if download_url.is_err() || signature.is_err() {
540+
log::debug!(
541+
"Bundle type is not known and fallback platform {} was not found in response",
542+
self.json_target
543+
);
544+
return Err(Error::TargetNotFound(self.json_target.clone()));
536545
}
537546

538547
let update = if should_update {

0 commit comments

Comments
 (0)