Behind a feature flag, update x64 macOS users to the arm64 build when possible

This commit is contained in:
Sergio Padrino 2021-04-08 16:21:45 +02:00
parent ba4c0dbb9e
commit dce4e0acea
3 changed files with 21 additions and 8 deletions

View file

@ -165,3 +165,8 @@ export function enableCherryPicking(): boolean {
export function enableTextDiffExpansion(): boolean {
return enableDevelopmentFeatures()
}
/** Should we allow apps running from Rosetta to auto-update to ARM64 builds? */
export function enableUpdateFromRosettaToARM64(): boolean {
return false
}

View file

@ -14,6 +14,7 @@ import { parseError } from '../../lib/squirrel-error-parser'
import { ReleaseSummary } from '../../models/release-notes'
import { generateReleaseSummary } from '../../lib/release-notes'
import { setNumber, getNumber } from '../../lib/local-storage'
import { enableUpdateFromRosettaToARM64 } from '../../lib/feature-flag'
/** The states the auto updater can be in. */
export enum UpdateStatus {
@ -160,10 +161,24 @@ class UpdateStore {
return
}
let updatesURL = __UPDATES_URL__
// If the app is running under Rosetta (i.e. it's a macOS x64 binary running
// on an arm64 machine), we need to tweak the update URL here to point at
// the arm64 binary.
if (
enableUpdateFromRosettaToARM64() &&
remote.app.runningUnderRosettaTranslation === true
) {
const url = new URL(updatesURL)
url.searchParams.set('architecture', 'arm64')
updatesURL = url.toString()
}
this.userInitiatedUpdate = !inBackground
try {
autoUpdater.setFeedURL({ url: __UPDATES_URL__ })
autoUpdater.setFeedURL({ url: updatesURL })
autoUpdater.checkForUpdates()
} catch (e) {
this.emitError(e)

View file

@ -152,13 +152,6 @@ export function getArchitecture(): 'arm64' | 'x64' {
return 'arm64'
}
// TODO: temporarily disable this to prevent upgrades from macOS users of the
// x64 version under Rosetta to the arm64 binary. This should be enabled again
// once we're confident about the arm64 build.
// if (remote.app.runningUnderRosettaTranslation === true) {
// return 'arm64'
// }
// TODO: Check if it's x64 running on an arm64 Windows with IsWow64Process2
// More info: https://www.rudyhuyn.com/blog/2017/12/13/how-to-detect-that-your-x86-application-runs-on-windows-on-arm/
// Right now (March 3, 2021) is not very important because support for x64