mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
Revert "Prefer machine's native arch on macOS"
This reverts commit ebcd68428e
.
This commit is contained in:
parent
ebcd68428e
commit
b036113786
@ -1,5 +1,4 @@
|
|||||||
const { app, autoUpdater, ipcMain } = require('electron');
|
const { app, autoUpdater, ipcMain } = require('electron');
|
||||||
const childProcess = require('child_process');
|
|
||||||
|
|
||||||
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
|
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
|
||||||
const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
|
const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
|
||||||
@ -20,7 +19,7 @@ function pollForUpdates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {};
|
module.exports = {};
|
||||||
module.exports.start = async function startAutoUpdate(updateBaseUrl) {
|
module.exports.start = function startAutoUpdate(updateBaseUrl) {
|
||||||
if (updateBaseUrl.slice(-1) !== '/') {
|
if (updateBaseUrl.slice(-1) !== '/') {
|
||||||
updateBaseUrl = updateBaseUrl + '/';
|
updateBaseUrl = updateBaseUrl + '/';
|
||||||
}
|
}
|
||||||
@ -32,30 +31,13 @@ module.exports.start = async function startAutoUpdate(updateBaseUrl) {
|
|||||||
// 204 No Content. On windows it takes a base path and looks for
|
// 204 No Content. On windows it takes a base path and looks for
|
||||||
// files under that path.
|
// files under that path.
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
// Check the machine's native architecture, which differs from
|
|
||||||
// `process.arch` when using emulation
|
|
||||||
let nativeArch = process.arch;
|
|
||||||
try {
|
|
||||||
nativeArch = await new Promise((resolve, reject) => {
|
|
||||||
childProcess.execFile('uname', ['-m'], (err, out) => {
|
|
||||||
if (err) {
|
|
||||||
reject("Failed to run uname");
|
|
||||||
}
|
|
||||||
resolve(out.trim());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Canonicalise to match `process.arch` naming
|
|
||||||
if (nativeArch === "x86_64") nativeArch = "x64";
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Failed to check native arch", e);
|
|
||||||
}
|
|
||||||
// include the current version in the URL we hit. Electron doesn't add
|
// include the current version in the URL we hit. Electron doesn't add
|
||||||
// it anywhere (apart from the User-Agent) so it's up to us. We could
|
// it anywhere (apart from the User-Agent) so it's up to us. We could
|
||||||
// (and previously did) just use the User-Agent, but this doesn't
|
// (and previously did) just use the User-Agent, but this doesn't
|
||||||
// rely on NSURLConnection setting the User-Agent to what we expect,
|
// rely on NSURLConnection setting the User-Agent to what we expect,
|
||||||
// and also acts as a convenient cache-buster to ensure that when the
|
// and also acts as a convenient cache-buster to ensure that when the
|
||||||
// app updates it always gets a fresh value to avoid update-looping.
|
// app updates it always gets a fresh value to avoid update-looping.
|
||||||
url = `${updateBaseUrl}macos/${nativeArch}/?localVersion=${encodeURIComponent(app.getVersion())}`;
|
url = `${updateBaseUrl}macos/${process.arch}/?localVersion=${encodeURIComponent(app.getVersion())}`;
|
||||||
} else if (process.platform === 'win32') {
|
} else if (process.platform === 'win32') {
|
||||||
url = `${updateBaseUrl}win32/${process.arch}/`;
|
url = `${updateBaseUrl}win32/${process.arch}/`;
|
||||||
} else {
|
} else {
|
||||||
@ -66,7 +48,6 @@ module.exports.start = async function startAutoUpdate(updateBaseUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
console.log(`Update URL: ${url}`);
|
|
||||||
autoUpdater.setFeedURL(url);
|
autoUpdater.setFeedURL(url);
|
||||||
// We check for updates ourselves rather than using 'updater' because we need to
|
// We check for updates ourselves rather than using 'updater' because we need to
|
||||||
// do it in the main process (and we don't really need to check every 10 minutes:
|
// do it in the main process (and we don't really need to check every 10 minutes:
|
||||||
|
Loading…
Reference in New Issue
Block a user