Skip to content

Commit e67750c

Browse files
committed
Rename some staffs
1 parent 0a495cc commit e67750c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

plugins/updater/src/updater.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,13 @@ impl UpdaterBuilder {
296296
return Err(Error::EmptyEndpoints);
297297
};
298298

299-
let arch = get_updater_arch().ok_or(Error::UnsupportedArch)?;
299+
let arch = updater_arch().ok_or(Error::UnsupportedArch)?;
300300
let (target, json_target) = if let Some(target) = self.target {
301301
(target.clone(), target)
302302
} else {
303-
let target = get_updater_target().ok_or(Error::UnsupportedOs)?;
304-
let json_target = format!("{target}-{arch}");
305-
(target.to_owned(), json_target)
303+
let os = updater_os().ok_or(Error::UnsupportedOs)?;
304+
let json_target = format!("{os}-{arch}");
305+
(os.to_owned(), json_target)
306306
};
307307

308308
let executable_path = self.executable_path.clone().unwrap_or(current_exe()?);
@@ -359,7 +359,8 @@ pub struct Updater {
359359
proxy: Option<Url>,
360360
endpoints: Vec<Url>,
361361
arch: &'static str,
362-
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON
362+
// The `{{target}}` variable we replace in the endpoint and serach for in the JSON,
363+
// this is either the user provided target or the current operating system by default
363364
target: String,
364365
// The value we search if the updater server returns a JSON with the `platforms` object
365366
json_target: String,
@@ -375,15 +376,15 @@ pub struct Updater {
375376

376377
impl Updater {
377378
fn get_updater_installer(&self) -> Option<Installer> {
378-
bundle_type().and_then(|t| match t {
379+
match bundle_type()? {
379380
BundleType::Deb => Some(Installer::Deb),
380381
BundleType::Rpm => Some(Installer::Rpm),
381382
BundleType::AppImage => Some(Installer::AppImage),
382383
BundleType::Msi => Some(Installer::Msi),
383384
BundleType::Nsis => Some(Installer::Nsis),
384385
BundleType::App => Some(Installer::App),
385386
BundleType::Dmg => None,
386-
})
387+
}
387388
}
388389

389390
pub async fn check(&self) -> Result<Option<Update>> {
@@ -518,7 +519,7 @@ impl Updater {
518519
if let Some(installer) = installer {
519520
let target = &format!("{}-{}", &self.json_target, installer.suffix());
520521
log::debug!(
521-
"Bundle type is {}. Checking for plattform {target} in response",
522+
"Bundle type is {}. Checking for platform {target} in response",
522523
installer.suffix()
523524
);
524525
let bundle_url = release.download_url(target);
@@ -530,9 +531,9 @@ impl Updater {
530531
target.clone(),
531532
));
532533
}
533-
log::debug!("Plattform {target} not found in response. Using fallback URL");
534+
log::debug!("Platform {target} not found in response. Using fallback URL");
534535
} else {
535-
log::debug!("Plattform {target} found in response");
536+
log::debug!("Platform {target} found in response");
536537
download_url = bundle_url;
537538
signature = bundle_signature;
538539
}
@@ -1275,14 +1276,14 @@ impl Update {
12751276

12761277
/// Gets the target string used on the updater.
12771278
pub fn target() -> Option<String> {
1278-
if let (Some(target), Some(arch)) = (get_updater_target(), get_updater_arch()) {
1279+
if let (Some(target), Some(arch)) = (updater_os(), updater_arch()) {
12791280
Some(format!("{target}-{arch}"))
12801281
} else {
12811282
None
12821283
}
12831284
}
12841285

1285-
pub(crate) fn get_updater_target() -> Option<&'static str> {
1286+
fn updater_os() -> Option<&'static str> {
12861287
if cfg!(target_os = "linux") {
12871288
Some("linux")
12881289
} else if cfg!(target_os = "macos") {
@@ -1295,7 +1296,7 @@ pub(crate) fn get_updater_target() -> Option<&'static str> {
12951296
}
12961297
}
12971298

1298-
pub(crate) fn get_updater_arch() -> Option<&'static str> {
1299+
fn updater_arch() -> Option<&'static str> {
12991300
if cfg!(target_arch = "x86") {
13001301
Some("i686")
13011302
} else if cfg!(target_arch = "x86_64") {

0 commit comments

Comments
 (0)