chore: edition 2024

This commit is contained in:
Lucas Nogueira
2026-09-26 15:36:22 -03:00
parent b517cc7e85
commit 3d8a3c877b
100 changed files with 276 additions and 253 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ use crate::{Result, Update, UpdaterExt};
use http::{HeaderMap, HeaderName, HeaderValue};
use serde::Serialize;
use tauri::{ipc::Channel, Manager, Resource, ResourceId, Runtime, Webview};
use tauri::{Manager, Resource, ResourceId, Runtime, Webview, ipc::Channel};
use std::{str::FromStr, time::Duration};
use url::Url;
+6 -2
View File
@@ -204,8 +204,12 @@ pub(crate) fn validate_endpoints(
if url.scheme() != "https" {
#[cfg(debug_assertions)]
{
eprintln!("[\x1b[33mWARNING\x1b[0m] The updater endpoint \"{url}\" doesn't use `https` protocol. This is allowed in development but will fail in release builds.");
eprintln!("[\x1b[33mWARNING\x1b[0m] if this is a desired behavior, you can enable `dangerousInsecureTransportProtocol` in the plugin configuration");
eprintln!(
"[\x1b[33mWARNING\x1b[0m] The updater endpoint \"{url}\" doesn't use `https` protocol. This is allowed in development but will fail in release builds."
);
eprintln!(
"[\x1b[33mWARNING\x1b[0m] if this is a desired behavior, you can enable `dangerousInsecureTransportProtocol` in the plugin configuration"
);
}
#[cfg(not(debug_assertions))]
return Err(crate::Error::InsecureTransportProtocol);
+7 -5
View File
@@ -25,7 +25,9 @@ pub enum Error {
#[error("Could not fetch a valid release JSON from the remote")]
ReleaseNotFound,
/// Unsupported app architecture.
#[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")]
#[error(
"Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`."
)]
UnsupportedArch,
/// Operating system is not supported.
#[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
@@ -43,9 +45,7 @@ pub enum Error {
#[error("the platform `{0}` was not found in the response `platforms` object")]
TargetNotFound(String),
/// Neither the platform nor the fallback platform was found in the updater JSON response.
#[error(
"None of the fallback platforms `{0:?}` were found in the response `platforms` object"
)]
#[error("None of the fallback platforms `{0:?}` were found in the response `platforms` object")]
TargetsNotFound(Vec<String>),
/// Download failed
#[error("`{0}`")]
@@ -57,7 +57,9 @@ pub enum Error {
#[error(transparent)]
Base64(#[from] base64::DecodeError),
/// UTF8 Errors in signature.
#[error("The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string.")]
#[error(
"The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string."
)]
SignatureUtf8(String),
#[cfg(all(target_os = "windows", feature = "zip"))]
/// `zip` errors.
+1 -1
View File
@@ -24,8 +24,8 @@ use std::{ffi::OsString, sync::Arc};
use http::{HeaderMap, HeaderName, HeaderValue};
use semver::Version;
use tauri::{
plugin::{Builder as PluginBuilder, TauriPlugin},
Manager, Runtime,
plugin::{Builder as PluginBuilder, TauriPlugin},
};
mod commands;
+15 -21
View File
@@ -17,28 +17,28 @@ use std::ffi::OsStr;
use base64::Engine;
use futures_util::StreamExt;
use http::{header::ACCEPT, HeaderName};
use http::{HeaderName, header::ACCEPT};
use minisign_verify::{PublicKey, Signature};
use percent_encoding::{AsciiSet, CONTROLS};
use reqwest::{
header::{HeaderMap, HeaderValue},
ClientBuilder, StatusCode,
header::{HeaderMap, HeaderValue},
};
use semver::Version;
use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize};
use serde::{Deserialize, Deserializer, Serialize, de::Error as DeError};
use tauri::{
AppHandle, Resource, Runtime,
utils::{
config::BundleType,
platform::{bundle_type, current_exe},
},
AppHandle, Resource, Runtime,
};
use time::OffsetDateTime;
use url::Url;
use crate::{
error::{Error, Result},
Config,
error::{Error, Result},
};
const UPDATER_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),);
@@ -937,8 +937,8 @@ impl Update {
/// └── ...
fn install_inner(&self, bytes: &[u8]) -> Result<()> {
use windows_sys::{
w,
Win32::UI::{Shell::ShellExecuteW, WindowsAndMessaging::SW_SHOW},
w,
};
let updater_type = self.extract(bytes)?;
@@ -1185,8 +1185,8 @@ impl Update {
let decoder = flate2::read::GzDecoder::new(archive);
let mut archive = tar::Archive::new(decoder);
for mut entry in archive.entries()?.flatten() {
if let Ok(path) = entry.path() {
if path.extension() == Some(OsStr::new("AppImage")) {
if let Ok(path) = entry.path()
&& path.extension() == Some(OsStr::new("AppImage")) {
// if something went wrong during the extraction, we should restore previous app
if let Err(err) = entry.unpack(&self.extract_path) {
std::fs::rename(tmp_app_image, &self.extract_path)?;
@@ -1195,7 +1195,6 @@ impl Update {
// early finish we have everything we need here
return Ok(());
}
}
}
// if we have not returned early we should restore the backup
std::fs::rename(tmp_app_image, &self.extract_path)?;
@@ -1289,20 +1288,17 @@ impl Update {
.arg(install_arg)
.arg(pkg_path)
.status()
{
if status.success() {
&& status.success() {
log::debug!("installed {pkg_path:?} with pkexec");
return Ok(());
}
}
// 2. Try zenity or kdialog for a graphical sudo experience
if let Ok(password) = self.get_password_graphically() {
if self.install_with_sudo(pkg_path, &password, install_cmd, install_arg)? {
if let Ok(password) = self.get_password_graphically()
&& self.install_with_sudo(pkg_path, &password, install_cmd, install_arg)? {
log::debug!("installed {pkg_path:?} with GUI sudo");
return Ok(());
}
}
// 3. Final fallback: terminal sudo
let status = std::process::Command::new("sudo")
@@ -1329,22 +1325,20 @@ impl Update {
])
.output();
if let Ok(output) = zenity_result {
if output.status.success() {
if let Ok(output) = zenity_result
&& output.status.success() {
return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string());
}
}
// Fall back to kdialog if zenity fails or isn't available
let kdialog_result = std::process::Command::new("kdialog")
.args(["--password", "Enter your password to install the update:"])
.output();
if let Ok(output) = kdialog_result {
if output.status.success() {
if let Ok(output) = kdialog_result
&& output.status.success() {
return Ok(String::from_utf8_lossy(&output.stdout).trim().to_string());
}
}
Err(Error::AuthenticationFailed)
}
@@ -818,7 +818,8 @@ fn run_update_cases(
if code != expected_exit_code {
panic!(
"failed to run app bundled as {}, expected exit code {expected_exit_code}, got {code}", bundle_target.name()
"failed to run app bundled as {}, expected exit code {expected_exit_code}, got {code}",
bundle_target.name()
);
}
#[cfg(windows)]
@@ -32,7 +32,7 @@ fn npm_command() -> Command {
}
mod v1 {
use super::{npm_command, BundleTarget, UPDATER_PRIVATE_KEY};
use super::{BundleTarget, UPDATER_PRIVATE_KEY, npm_command};
use serde::Serialize;
use std::{
path::{Path, PathBuf},
@@ -3,7 +3,7 @@ workspace = {}
[package]
name = "app-updater-v1"
version = "0.1.0"
edition = "2021"
edition = "2024"
[build-dependencies]
tauri-build = { version = "1", features = [] }