Add in-app updater: check Gitea releases, show changelog, download + run installer
A new Settings → "Software update" card lets users update AeroFetch from inside the app: - src/main/updater.ts — queries the configured Gitea repo's latest release over the public REST API, compares the tag to app.getVersion(), and (on request) streams the installer asset to the OS temp dir with progress events, then launches it and quits so it can replace the app. - Security: only the trusted update host over HTTPS is ever downloaded from, and only a freshly-downloaded .exe inside our temp dir is ever executed — the download URL from the release JSON can't redirect us elsewhere. No token is ever shipped; the source repo must be anonymously readable (public). - IPC: app:update-check / -download / -run + an -progress push channel, exposed via preload (checkForAppUpdate / downloadAppUpdate / runAppUpdate / onAppUpdateProgress). - UI: "Check for updates" → shows the new version and its release notes, then "Update now" (with a download progress bar) or "View release". Up-to-date and error states handled. Preview mock added so the flow is exercisable in `npm run ui`. Note: the update source repo/host are constants at the top of updater.ts (currently debont80/AeroFetch). Downloads work once the release repo is public and the Gitea instance allows anonymous API + asset access. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,14 @@
|
||||
export const IpcChannels = {
|
||||
/** the AeroFetch app version (package.json / app.getVersion) */
|
||||
appVersion: 'app:version',
|
||||
/** check the configured Gitea repo for a newer AeroFetch release */
|
||||
appUpdateCheck: 'app:update-check',
|
||||
/** download the latest release's installer to a temp file */
|
||||
appUpdateDownload: 'app:update-download',
|
||||
/** launch a downloaded installer and quit so it can replace the app */
|
||||
appUpdateRun: 'app:update-run',
|
||||
/** main → renderer push channel for installer download progress */
|
||||
appUpdateProgress: 'app:update-progress',
|
||||
ytdlpVersion: 'ytdlp:version',
|
||||
probe: 'media:probe',
|
||||
downloadStart: 'download:start',
|
||||
@@ -188,6 +196,45 @@ export interface YtdlpVersionResult {
|
||||
error?: string
|
||||
}
|
||||
|
||||
/** Result of checking the configured Gitea repo for a newer AeroFetch release. */
|
||||
export interface AppUpdateInfo {
|
||||
ok: boolean
|
||||
/** true when latestVersion is newer than the running app */
|
||||
available: boolean
|
||||
/** the running app's version, e.g. '0.4.0' */
|
||||
currentVersion: string
|
||||
/** the latest release's version (tag without a leading 'v'), when ok */
|
||||
latestVersion?: string
|
||||
/** the release notes / changelog body (Markdown), shown before updating */
|
||||
notes?: string
|
||||
/** the release's web page on Gitea (for "View release") */
|
||||
htmlUrl?: string
|
||||
/** direct download URL of the Windows installer asset, when the release has one */
|
||||
downloadUrl?: string
|
||||
/** the installer asset's file name */
|
||||
assetName?: string
|
||||
/** human-readable error, when ok is false */
|
||||
error?: string
|
||||
}
|
||||
|
||||
/** Result of downloading the update installer to a temp file. */
|
||||
export interface AppUpdateDownload {
|
||||
ok: boolean
|
||||
/** absolute path to the downloaded installer, when ok */
|
||||
filePath?: string
|
||||
error?: string
|
||||
}
|
||||
|
||||
/** Live progress of the installer download (main → renderer). */
|
||||
export interface AppUpdateProgress {
|
||||
/** bytes downloaded so far */
|
||||
received: number
|
||||
/** total bytes, when the server reports Content-Length */
|
||||
total?: number
|
||||
/** 0..1 fraction, when total is known */
|
||||
fraction?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* yt-dlp's self-update release channels (`--update-to <channel>`).
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user