From 6d97b15591df2cfc61ebf0bae767290eb6af027d Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Tue, 25 Jun 2024 12:50:17 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20appUpdater=20support=20AR?= =?UTF-8?q?M64=20(#2327)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ARM64 support for the appUpdater --- .../electron-app/src/helpers/app-updater.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ui/desktop/electron-app/src/helpers/app-updater.js b/ui/desktop/electron-app/src/helpers/app-updater.js index 2c4cc2cf8..450a3a77e 100644 --- a/ui/desktop/electron-app/src/helpers/app-updater.js +++ b/ui/desktop/electron-app/src/helpers/app-updater.js @@ -8,9 +8,10 @@ const path = require('path'); const https = require('https'); const semver = require('semver'); const { parse } = require('node-html-parser'); -const { autoUpdater, dialog } = require('electron'); +const { autoUpdater, dialog, app } = require('electron'); const { isWindows, isLinux } = require('../helpers/platform.js'); const config = require('../../config/config.js'); +const log = require('electron-log/main'); let currentVersion = config.releaseVersion; const debug = process.env.DEBUG_APP_UPDATER; @@ -19,6 +20,24 @@ if (debug && process.env.APP_UPDATER_CURRENT_VERSION) { currentVersion = process.env.APP_UPDATER_CURRENT_VERSION; } +// Returns the real CPU architecture of the machine. +const returnArchitectureToUpdate = () => { + const nodeArchitecture = process.arch; + + if (nodeArchitecture === 'arm64') { + return nodeArchitecture; + } + + try { + if (app.runningUnderARM64Translation) { + return 'arm64'; + } + } catch (err) { + log.error(`returnArchitectureToUpdate: ${err}`); + } + return nodeArchitecture; +}; + // Query releases url to find latest version const findLatestVersion = (url) => { return new Promise((resolve, reject) => { @@ -38,7 +57,8 @@ const findLatestVersion = (url) => { // Find zip archive for update const findUpdateArchive = (version) => { - const url = `${releasesUrl}${version}/boundary-desktop_${version}_darwin_amd64.zip`; + const architecture = returnArchitectureToUpdate(); + const url = `${releasesUrl}${version}/boundary-desktop_${version}_darwin_${architecture}.zip`; return new Promise((resolve, reject) => { https.get(url, (response) => { if (response.statusCode === 403)