33 *
44 * Event translation table (electron-updater → AppUpdateStatusJson.state):
55 * checking-for-update → "checking"
6- * update-available → "available" (manual) or "downloading" (auto )
6+ * update-available → "available" (user chooses when to download )
77 * update-not-available → "up-to-date"
88 * download-progress → "downloading" (with 0–100 progress)
99 * update-downloaded → "ready" (updateReady → user can restart)
1616import { app } from "electron" ;
1717import pkg from "electron-updater" ;
1818import type { AppUpdateStatusJson } from "../shared/rpc-schema" ;
19- import { readSettings } from "./settings" ;
2019
2120const { autoUpdater } = pkg ;
2221
@@ -31,12 +30,6 @@ let lastError: string | null = null;
3130let state : AppUpdateStatusJson [ "state" ] = "idle" ;
3231let updateDownloaded = false ;
3332let downloadPromise : Promise < string [ ] > | null = null ;
34- let autoDownloadUpdates = true ;
35-
36- function refreshAutoDownloadPreference ( ) : void {
37- autoDownloadUpdates = readSettings ( ) . auto_download_updates !== false ;
38- autoUpdater . autoDownload = autoDownloadUpdates ;
39- }
4033
4134function snapshot ( ) : AppUpdateStatusJson {
4235 return {
@@ -67,7 +60,7 @@ function setState(next: AppUpdateStatusJson["state"]): void {
6760}
6861
6962function wireAutoUpdaterEvents ( ) : void {
70- refreshAutoDownloadPreference ( ) ;
63+ autoUpdater . autoDownload = false ;
7164 autoUpdater . autoInstallOnAppQuit = true ;
7265
7366 autoUpdater . on ( "checking-for-update" , ( ) => {
@@ -80,7 +73,7 @@ function wireAutoUpdaterEvents(): void {
8073 remoteVersion = info ?. version ?? null ;
8174 downloadProgress = null ;
8275 updateDownloaded = false ;
83- setState ( autoDownloadUpdates ? "downloading" : "available" ) ;
76+ setState ( "available" ) ;
8477 } ) ;
8578
8679 autoUpdater . on ( "update-not-available" , ( ) => {
@@ -122,16 +115,15 @@ export function initAppUpdater(
122115
123116 wireAutoUpdaterEvents ( ) ;
124117
125- // Fire-and-forget initial check, then poll every 6h.
126- refreshAutoDownloadPreference ( ) ;
118+ // Fire-and-forget initial check, then poll every 6h. Downloads are always
119+ // user-initiated to avoid uncontrolled release traffic spikes.
127120 void autoUpdater . checkForUpdates ( ) . catch ( ( err ) => {
128121 lastError = err ?. message ?? String ( err ) ;
129122 setState ( "error" ) ;
130123 } ) ;
131124
132125 recheckTimer = setInterval (
133126 ( ) => {
134- refreshAutoDownloadPreference ( ) ;
135127 void autoUpdater . checkForUpdates ( ) . catch ( ( err ) => {
136128 lastError = err ?. message ?? String ( err ) ;
137129 setState ( "error" ) ;
@@ -160,7 +152,6 @@ export function getAppUpdateStatus(): AppUpdateStatusJson {
160152export async function checkForUpdate ( ) : Promise < AppUpdateStatusJson > {
161153 if ( ! app . isPackaged ) return snapshot ( ) ;
162154 try {
163- refreshAutoDownloadPreference ( ) ;
164155 await autoUpdater . checkForUpdates ( ) ;
165156 } catch ( err ) {
166157 lastError = ( err as Error ) ?. message ?? String ( err ) ;
0 commit comments