Skip to content

Commit

Permalink
Add RD_FORCE_UPDATES_ENABLED env var
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Pickering <adam.pickering@suse.com>
  • Loading branch information
adamkpickering committed May 9, 2023
1 parent 66af8d0 commit f0753d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
owner: rancher-sandbox
repo: rancher-desktop
updaterCacheDirName: rancher-desktop
provider: custom
upgradeServer: https://desktop.version.rancher.io/v1/checkupgrade
vPrefixedTagName: true
8 changes: 7 additions & 1 deletion pkg/rancher-desktop/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ export function load(deploymentProfiles: DeploymentProfileType): Settings {
settings.virtualMachine.memoryInGB = Math.min(6, Math.round(totalMemoryInGB / 4.0));
}
}
if (os.platform() === 'linux' && !process.env['APPIMAGE']) {

// determine whether updates should be enabled
if (process.env.RD_FORCE_UPDATES_ENABLED) {
console.debug('updates enabled via RD_FORCE_UPDATES_ENABLED');
settings.application.updater.enabled = true;
} else if (os.platform() === 'linux' && !process.env.APPIMAGE) {
settings.application.updater.enabled = false;
} else {
const appVersion = getProductionVersion();
Expand All @@ -267,6 +272,7 @@ export function load(deploymentProfiles: DeploymentProfileType): Settings {
console.log('updates disabled');
}
}

_.merge(settings, deploymentProfiles.locked);
save(settings);
lockedSettings = determineLockedFields(deploymentProfiles.locked);
Expand Down
10 changes: 8 additions & 2 deletions pkg/rancher-desktop/main/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Electron.ipcMain.on('update-apply', () => {
if (!autoUpdater) {
return;
}
autoUpdater.quitAndInstall();
quitAndInstallUpdate();
});

function isLonghornUpdateInfo(info: UpdateInfo | LonghornUpdateInfo): info is LonghornUpdateInfo {
Expand Down Expand Up @@ -259,7 +259,7 @@ async function doInitialUpdateCheck(doInstall = false): Promise<boolean> {
autoUpdater.once('update-downloaded', () => {
console.log('Update download complete; restarting app');
setHasQueuedUpdate(true);
autoUpdater.quitAndInstall(true, true);
quitAndInstallUpdate(true, true);
console.log(`Install complete, result: ${ !hasError }`);
resolve(!hasError);
});
Expand Down Expand Up @@ -302,3 +302,9 @@ async function triggerUpdateCheck() {
}
updateTimer = timers.setTimeout(triggerUpdateCheck, updateInterval);
}

function quitAndInstallUpdate(isSilent?: boolean, isForceRunAfter?: boolean): void {
if (!process.env.RD_FORCE_UPDATES_ENABLED) {
autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
}
}

0 comments on commit f0753d9

Please sign in to comment.