feat: Add DISABLE_AUTO_UPDATES env variable for disabling updates in the application entirely (#1446)

This commit is contained in:
BatteredBunny
2025-12-28 10:50:55 +02:00
committed by GitHub
parent e821397e6c
commit 63015195b0
4 changed files with 16 additions and 5 deletions
+2 -1
View File
@@ -30,6 +30,7 @@ import MenuBuilder from './menu';
import { import {
autoUpdaterLogInterface, autoUpdaterLogInterface,
createLog, createLog,
disableAutoUpdates,
hotkeyToElectronAccelerator, hotkeyToElectronAccelerator,
isLinux, isLinux,
isMacOS, isMacOS,
@@ -456,7 +457,7 @@ async function createWindow(first = true): Promise<void> {
return { action: 'deny' }; return { action: 'deny' };
}); });
if (store.get('disable_auto_updates') !== true) { if (!disableAutoUpdates() && store.get('disable_auto_updates') !== true) {
new AppUpdater(); new AppUpdater();
} }
+4
View File
@@ -18,6 +18,10 @@ if (process.env.NODE_ENV === 'development') {
}; };
} }
export const disableAutoUpdates = () => {
return process.env['DISABLE_AUTO_UPDATES'];
};
export const isMacOS = () => { export const isMacOS = () => {
return process.platform === 'darwin'; return process.platform === 'darwin';
}; };
+2 -1
View File
@@ -1,6 +1,6 @@
import { ipcRenderer, IpcRendererEvent } from 'electron'; import { ipcRenderer, IpcRendererEvent } from 'electron';
import { isLinux, isMacOS, isWindows } from '../main/utils'; import { disableAutoUpdates, isLinux, isMacOS, isWindows } from '../main/utils';
const openItem = async (path: string) => { const openItem = async (path: string) => {
return ipcRenderer.invoke('open-item', path); return ipcRenderer.invoke('open-item', path);
@@ -40,6 +40,7 @@ const download = (url: string) => {
}; };
export const utils = { export const utils = {
disableAutoUpdates,
download, download,
isLinux, isLinux,
isMacOS, isMacOS,
@@ -10,6 +10,11 @@ import { Select } from '/@/shared/components/select/select';
import { Switch } from '/@/shared/components/switch/switch'; import { Switch } from '/@/shared/components/switch/switch';
const localSettings = isElectron() ? window.api.localSettings : null; const localSettings = isElectron() ? window.api.localSettings : null;
const utils = isElectron() ? window.api.utils : null;
function disableAutoUpdates(): boolean {
return !isElectron() || utils?.disableAutoUpdates();
}
export const UpdateSettings = () => { export const UpdateSettings = () => {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -55,7 +60,7 @@ export const UpdateSettings = () => {
context: 'description', context: 'description',
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
}), }),
isHidden: !isElectron(), isHidden: disableAutoUpdates(),
title: t('setting.releaseChannel', { postProcess: 'sentenceCase' }), title: t('setting.releaseChannel', { postProcess: 'sentenceCase' }),
}, },
{ {
@@ -63,7 +68,7 @@ export const UpdateSettings = () => {
<Switch <Switch
aria-label="Disable automatic updates" aria-label="Disable automatic updates"
defaultChecked={settings.disableAutoUpdate} defaultChecked={settings.disableAutoUpdate}
disabled={!isElectron()} disabled={disableAutoUpdates()}
onChange={(e) => { onChange={(e) => {
if (!e) return; if (!e) return;
localSettings?.set('disable_auto_updates', e.currentTarget.checked); localSettings?.set('disable_auto_updates', e.currentTarget.checked);
@@ -80,7 +85,7 @@ export const UpdateSettings = () => {
context: 'description', context: 'description',
postProcess: 'sentenceCase', postProcess: 'sentenceCase',
}), }),
isHidden: !isElectron(), isHidden: disableAutoUpdates(),
title: t('setting.disableAutomaticUpdates', { postProcess: 'sentenceCase' }), title: t('setting.disableAutomaticUpdates', { postProcess: 'sentenceCase' }),
}, },
]; ];