feat(updater): download and prepare desktop updates in background
This commit is contained in:
77 files changed
+10536
-814
No files matched your search
@@ -833,6 +833,8 @@ export const fetchChangelog = forward("fetchChangelog");
|
||||
export const getSystemProxyUrl = forward("getSystemProxyUrl");
|
||||
export const downloadUpdate = forward("downloadUpdate");
|
||||
export const cancelUpdateDownload = forward("cancelUpdateDownload");
|
||||
export const getDownloadedUpdate = forward("getDownloadedUpdate");
|
||||
export const discardDownloadedUpdate = forward("discardDownloadedUpdate");
|
||||
export const installDownloadedUpdate = forward("installDownloadedUpdate");
|
||||
export const getAppVersion = forward("getAppVersion");
|
||||
export const getAppSupportInfo = forward("getAppSupportInfo");
|
||||
@@ -891,6 +893,7 @@ export type {
|
||||
McpHttpServerStatus,
|
||||
WebMcpHttpStatus,
|
||||
UpdateInfo,
|
||||
DownloadedUpdate,
|
||||
RedisBlob,
|
||||
RedisCollectionPage,
|
||||
RedisDatabaseInfo,
|
||||
|
||||
@@ -77,6 +77,7 @@ import type {
|
||||
DriverInstallProgress,
|
||||
JavaRuntimeConfig,
|
||||
UpdateInfo,
|
||||
DownloadedUpdate,
|
||||
UpdateDownloadSource,
|
||||
RedisCollectionPage,
|
||||
RedisDatabaseInfo,
|
||||
@@ -4482,13 +4483,19 @@ export async function getSystemProxyUrl(): Promise<string | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function downloadUpdate(_source: UpdateDownloadSource, _latestVersion?: string): Promise<void> {
|
||||
export async function downloadUpdate(_source: UpdateDownloadSource, _latestVersion: string, _attemptId: string, _releaseNotes?: string): Promise<DownloadedUpdate> {
|
||||
throw new Error("In-app update downloads are only available in the desktop app.");
|
||||
}
|
||||
|
||||
export async function cancelUpdateDownload(): Promise<void> {}
|
||||
|
||||
export async function installDownloadedUpdate(): Promise<void> {
|
||||
export async function getDownloadedUpdate(): Promise<DownloadedUpdate | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function discardDownloadedUpdate(_cacheId: string): Promise<void> {}
|
||||
|
||||
export async function installDownloadedUpdate(_cacheId: string, _expectedVersion: string): Promise<void> {
|
||||
throw new Error("In-app update installation is only available in the desktop app.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { invoke as tauriInvoke } from "@tauri-apps/api/core";
|
||||
import { assertUpdateAllowsCommand } from "@/lib/app/updatePreparation";
|
||||
|
||||
function invoke<T>(command: string, args?: Record<string, unknown>): Promise<T> {
|
||||
assertUpdateAllowsCommand(command);
|
||||
return tauriInvoke<T>(command, args);
|
||||
}
|
||||
import type { DetachedTabHandoff } from "@/lib/app/detachedTabHandoff";
|
||||
import { BackendErrorException, type BackendError } from "@/lib/backend/errorUtils";
|
||||
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
||||
@@ -2469,7 +2475,18 @@ export interface UpdateInfo {
|
||||
|
||||
export type UpdateDownloadSource = "official" | "cnb";
|
||||
|
||||
export interface DownloadedUpdate {
|
||||
cache_id: string;
|
||||
version: string;
|
||||
portable_mode: boolean;
|
||||
release_url: string;
|
||||
release_notes: string;
|
||||
downloaded_at: number;
|
||||
}
|
||||
|
||||
export interface UpdateDownloadProgress {
|
||||
attempt_id: string;
|
||||
version: string;
|
||||
downloaded: number;
|
||||
total: number | null;
|
||||
}
|
||||
@@ -2516,16 +2533,24 @@ export async function getSystemProxyUrl(): Promise<string | null> {
|
||||
return invoke("get_system_proxy_url");
|
||||
}
|
||||
|
||||
export async function downloadUpdate(source: UpdateDownloadSource, latestVersion?: string): Promise<void> {
|
||||
return invoke("download_update", { source, latestVersion });
|
||||
export async function downloadUpdate(source: UpdateDownloadSource, latestVersion: string, attemptId: string, releaseNotes?: string): Promise<DownloadedUpdate> {
|
||||
return invoke("download_update", { source, latestVersion, attemptId, releaseNotes });
|
||||
}
|
||||
|
||||
export async function cancelUpdateDownload(): Promise<void> {
|
||||
return invoke("cancel_update_download");
|
||||
}
|
||||
|
||||
export async function installDownloadedUpdate(): Promise<void> {
|
||||
return invoke("install_downloaded_update");
|
||||
export async function getDownloadedUpdate(): Promise<DownloadedUpdate | null> {
|
||||
return invoke("get_downloaded_update");
|
||||
}
|
||||
|
||||
export async function discardDownloadedUpdate(cacheId: string): Promise<void> {
|
||||
return invoke("discard_downloaded_update", { cacheId });
|
||||
}
|
||||
|
||||
export async function installDownloadedUpdate(cacheId: string, expectedVersion: string): Promise<void> {
|
||||
return invoke("install_downloaded_update", { cacheId, expectedVersion });
|
||||
}
|
||||
|
||||
export async function getAppVersion(): Promise<string> {
|
||||
|
||||
Reference in new issue
Block a user