Skip to content

Commit b62e132

Browse files
committed
suggestios
1 parent a52b2b9 commit b62e132

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

plugins/updater/src/updater.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,6 @@ pub struct Updater {
365365
}
366366

367367
impl Updater {
368-
fn get_updater_installer(&self) -> Option<Installer> {
369-
match bundle_type()? {
370-
BundleType::Deb => Some(Installer::Deb),
371-
BundleType::Rpm => Some(Installer::Rpm),
372-
BundleType::AppImage => Some(Installer::AppImage),
373-
BundleType::Msi => Some(Installer::Msi),
374-
BundleType::Nsis => Some(Installer::Nsis),
375-
BundleType::App => Some(Installer::App),
376-
BundleType::Dmg => None,
377-
}
378-
}
379-
380368
pub async fn check(&self) -> Result<Option<Update>> {
381369
// we want JSON only
382370
let mut headers = self.headers.clone();
@@ -506,7 +494,7 @@ impl Updater {
506494
None => release.version > self.current_version,
507495
};
508496

509-
let installer = self.get_updater_installer();
497+
let installer = installer_for_bundle_type(bundle_type());
510498
let (download_url, signature) = self.get_urls(&release, &installer)?;
511499

512500
let update = if should_update {
@@ -523,7 +511,6 @@ impl Updater {
523511
download_url: download_url.clone(),
524512
signature: signature.to_owned(),
525513
body: release.notes,
526-
installer,
527514
raw_json: raw_json.unwrap(),
528515
timeout: None,
529516
proxy: self.proxy.clone(),
@@ -590,8 +577,6 @@ pub struct Update {
590577
/// The `{{target}}` variable we replace in the endpoint and search for in the JSON,
591578
/// this is either the user provided target or the current operating system by default
592579
pub target: String,
593-
/// Current installer type
594-
pub installer: Option<Installer>,
595580
/// Download URL announced
596581
pub download_url: Url,
597582
/// Signature announced
@@ -931,7 +916,7 @@ impl Update {
931916
/// └── ...
932917
///
933918
fn install_inner(&self, bytes: &[u8]) -> Result<()> {
934-
match self.installer {
919+
match installer_for_bundle_type(bundle_type()) {
935920
Some(Installer::Deb) => self.install_deb(bytes),
936921
Some(Installer::Rpm) => self.install_rpm(bytes),
937922
_ => self.install_appimage(bytes),
@@ -1389,6 +1374,18 @@ impl<'de> Deserialize<'de> for RemoteRelease {
13891374
}
13901375
}
13911376

1377+
fn installer_for_bundle_type(bundle: Option<BundleType>) -> Option<Installer> {
1378+
match bundle? {
1379+
BundleType::Deb => Some(Installer::Deb),
1380+
BundleType::Rpm => Some(Installer::Rpm),
1381+
BundleType::AppImage => Some(Installer::AppImage),
1382+
BundleType::Msi => Some(Installer::Msi),
1383+
BundleType::Nsis => Some(Installer::Nsis),
1384+
BundleType::App => Some(Installer::App),
1385+
_ => None,
1386+
}
1387+
}
1388+
13921389
fn parse_version<'de, D>(deserializer: D) -> std::result::Result<Version, D::Error>
13931390
where
13941391
D: serde::Deserializer<'de>,

0 commit comments

Comments
 (0)