mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-27 07:40:05 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2905b0a194 |
Generated
+11
-11
@@ -1127,7 +1127,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml_ng",
|
||||
"sha2 0.11.2",
|
||||
"sha2 0.11.1",
|
||||
"socket2",
|
||||
"specta",
|
||||
"specta-typescript",
|
||||
@@ -1234,7 +1234,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.11.2",
|
||||
"sha2 0.11.1",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"sysproxy",
|
||||
@@ -1329,7 +1329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3373,7 +3373,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.62.2",
|
||||
"windows-core 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4126,7 +4126,7 @@ version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef1d73c59a56771343712b22ea5615092c612c16ba291c0979e3105dfeec4890"
|
||||
dependencies = [
|
||||
"sha2 0.11.2",
|
||||
"sha2 0.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4961,7 +4961,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6739,9 +6739,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.11.2"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b0e5c7d67bc53f435386b2130fdc900488c5703770f6d8a4633060e34288a27"
|
||||
checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures 0.3.0",
|
||||
@@ -7393,7 +7393,7 @@ dependencies = [
|
||||
"semver 1.0.28",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2 0.11.2",
|
||||
"sha2 0.11.1",
|
||||
"syn 2.0.119",
|
||||
"tauri-utils",
|
||||
"thiserror 2.0.20",
|
||||
@@ -7928,7 +7928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.4.3",
|
||||
"getrandom 0.3.4",
|
||||
"once_cell",
|
||||
"rustix 1.1.4",
|
||||
"windows-sys 0.61.2",
|
||||
@@ -9257,7 +9257,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -80,7 +80,7 @@ flate2 = "1.1.11"
|
||||
reqwest_dav = "0.4.0"
|
||||
aes-gcm = { version = "0.11.1" }
|
||||
base64 = "0.23.1"
|
||||
sha2 = "0.11.2"
|
||||
sha2 = "0.11.1"
|
||||
getrandom = "0.4.3"
|
||||
futures = "0.3.34"
|
||||
gethostname = "1.1.0"
|
||||
|
||||
@@ -181,7 +181,8 @@ fn nsis_language_id(app_language: &str) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// Same wire shape as the updater plugin's JS `DownloadEvent`.
|
||||
/// Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
|
||||
/// install starts.
|
||||
#[derive(Clone, Serialize, specta::Type)]
|
||||
#[serde(tag = "event", content = "data")]
|
||||
pub enum DownloadEvent {
|
||||
@@ -194,12 +195,17 @@ pub enum DownloadEvent {
|
||||
chunk_length: usize,
|
||||
},
|
||||
Finished,
|
||||
Installing,
|
||||
}
|
||||
|
||||
const MIRRORS: [&str; 2] = ["https://update.hwdns.net/", "https://gh-proxy.org/"];
|
||||
/// A source delivering less than this per window is dropped for the next one.
|
||||
const MIN_PROGRESS: u64 = 1024 * 1024;
|
||||
const PROGRESS_WINDOW: Duration = Duration::from_secs(30);
|
||||
#[cfg(target_os = "windows")]
|
||||
const INSTALL_TIMEOUT: Duration = Duration::from_secs(30);
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
const INSTALL_TIMEOUT: Duration = Duration::from_secs(120);
|
||||
|
||||
/// The manifest's URL, then the other mirror, then GitHub itself.
|
||||
fn download_sources(url: &tauri::Url) -> Vec<tauri::Url> {
|
||||
@@ -292,8 +298,18 @@ impl SilentUpdater {
|
||||
Ok(updater_builder.build()?.check().await?)
|
||||
}
|
||||
|
||||
/// Installs verified bytes, dropping the cache first so a failure leaves nothing to
|
||||
/// re-trigger. A timeout abandons the await, not the detached install task; a successful
|
||||
/// Windows install exits the process inside the plugin (#2558).
|
||||
async fn install(update: Update, bytes: Vec<u8>) -> Result<()> {
|
||||
Ok(tokio::task::spawn_blocking(move || update.install(&bytes)).await??)
|
||||
Self::delete_cache();
|
||||
let install = tokio::task::spawn_blocking(move || update.install(&bytes));
|
||||
match tokio::time::timeout(INSTALL_TIMEOUT, install).await {
|
||||
Ok(result) => Ok(result??),
|
||||
Err(_) => Err(anyhow::anyhow!(
|
||||
"install timed out after {INSTALL_TIMEOUT:?}; it may still finish in the background"
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs a newer cached update before normal startup, if the user confirms.
|
||||
@@ -368,23 +384,13 @@ impl SilentUpdater {
|
||||
|
||||
Self::show_update_splash(app_handle, &version);
|
||||
|
||||
// `install()` may hang (#2558); on Windows NSIS can take over without returning.
|
||||
let install = tokio::time::timeout(std::time::Duration::from_secs(30), Self::install(update, bytes));
|
||||
match install
|
||||
.await
|
||||
.unwrap_or_else(|_| Err(anyhow::anyhow!("install timed out (30s)")))
|
||||
{
|
||||
match Self::install(update, bytes).await {
|
||||
Ok(()) => {
|
||||
logging!(info, Type::System, "Update v{version} install triggered at startup");
|
||||
Self::delete_cache();
|
||||
logging!(info, Type::System, "Update v{version} installed at startup");
|
||||
true
|
||||
}
|
||||
Err(e) => {
|
||||
logging!(
|
||||
warn,
|
||||
Type::System,
|
||||
"Startup install failed: {e:#}, will retry next launch"
|
||||
);
|
||||
logging!(warn, Type::System, "Startup install failed: {e:#}");
|
||||
Self::close_update_splash(app_handle);
|
||||
false
|
||||
}
|
||||
@@ -402,7 +408,7 @@ impl SilentUpdater {
|
||||
let cancel = CancellationToken::new();
|
||||
*self.manual_cancel.lock() = Some(cancel.clone());
|
||||
let prepared = tokio::select! {
|
||||
prepared = Self::prepare_install(app_handle, version, on_event) => Some(prepared),
|
||||
prepared = Self::prepare_install(app_handle, version, &on_event) => Some(prepared),
|
||||
() = cancel.cancelled() => None,
|
||||
};
|
||||
// `cancel_download` cancels under the lock, so once the token is taken back its state is
|
||||
@@ -417,15 +423,15 @@ impl SilentUpdater {
|
||||
};
|
||||
|
||||
logging!(info, Type::System, "Installing update v{version}...");
|
||||
on_event(DownloadEvent::Installing);
|
||||
Self::install(update, bytes).await?;
|
||||
Self::delete_cache();
|
||||
Ok(InstallUpdateOutcome::Installed)
|
||||
}
|
||||
|
||||
async fn prepare_install(
|
||||
app_handle: &tauri::AppHandle,
|
||||
version: &str,
|
||||
on_event: impl Fn(DownloadEvent) + Sync,
|
||||
on_event: &(impl Fn(DownloadEvent) + Sync),
|
||||
) -> Result<Option<(Update, Vec<u8>)>> {
|
||||
let Some(update) = Self::check(app_handle)
|
||||
.await?
|
||||
|
||||
@@ -267,6 +267,9 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
|
||||
})
|
||||
const { downloaded, total } = download
|
||||
|
||||
// Install cannot be cancelled; only the download can.
|
||||
const [installing, setInstalling] = useState(false)
|
||||
|
||||
const progress = total <= 0 ? 0 : Math.min((downloaded / total) * 100, 100)
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
@@ -333,6 +336,8 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
|
||||
...prev,
|
||||
total: prev.total || prev.downloaded,
|
||||
}))
|
||||
} else if (event.event === 'Installing') {
|
||||
setInstalling(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +371,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
|
||||
} finally {
|
||||
setUpdateState(false)
|
||||
setDownload({ downloaded: 0, total: 0 })
|
||||
setInstalling(false)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -419,6 +425,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
|
||||
}}
|
||||
okBtn={t('settings.modals.update.actions.update')}
|
||||
cancelBtn={t('shared.actions.cancel')}
|
||||
disableCancel={installing}
|
||||
onClose={() => setOpen(false)}
|
||||
onCancel={() => {
|
||||
if (updateState) {
|
||||
@@ -560,7 +567,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
|
||||
</Box>
|
||||
{updateState && (
|
||||
<LinearProgress
|
||||
variant={total > 0 ? 'determinate' : 'indeterminate'}
|
||||
variant={total > 0 && !installing ? 'determinate' : 'indeterminate'}
|
||||
value={progress}
|
||||
sx={{ mt: 1 }}
|
||||
/>
|
||||
|
||||
@@ -260,10 +260,16 @@ export type DnsOverrideOutcome =
|
||||
| { status: 'applied' }
|
||||
| { status: 'confirmation_required'; source: string }
|
||||
|
||||
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
|
||||
/**
|
||||
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
|
||||
* install starts.
|
||||
*/
|
||||
export type DownloadEvent = DownloadEvent_Serialize | DownloadEvent_Deserialize
|
||||
|
||||
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
|
||||
/**
|
||||
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
|
||||
* install starts.
|
||||
*/
|
||||
export type DownloadEvent_Deserialize =
|
||||
| {
|
||||
event: 'Started'
|
||||
@@ -278,8 +284,12 @@ export type DownloadEvent_Deserialize =
|
||||
}
|
||||
}
|
||||
| { event: 'Finished' }
|
||||
| { event: 'Installing' }
|
||||
|
||||
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
|
||||
/**
|
||||
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
|
||||
* install starts.
|
||||
*/
|
||||
export type DownloadEvent_Serialize =
|
||||
| {
|
||||
event: 'Started'
|
||||
@@ -294,6 +304,7 @@ export type DownloadEvent_Serialize =
|
||||
}
|
||||
}
|
||||
| { event: 'Finished' }
|
||||
| { event: 'Installing' }
|
||||
|
||||
/** Operation associated with a pending failure. */
|
||||
export type FailedOperation =
|
||||
|
||||
Reference in New Issue
Block a user