1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-07 09:31:31 +01:00

updater can only run on certain installations

This commit is contained in:
Kyle Spearrin 2018-02-23 15:23:21 -05:00
parent e3c5e3e706
commit 7d25b1462c
2 changed files with 24 additions and 4 deletions

View File

@ -10,6 +10,9 @@ import { Main } from '../main';
import {
isAppImage,
isDev,
isMacAppStore,
isWindowsPortable,
isWindowsStore,
} from '../scripts/utils';
const UpdaterCheckInitalDelay = 5 * 1000; // 5 seconds
@ -18,8 +21,14 @@ const UpdaterCheckInterval = 12 * 60 * 60 * 1000; // 12 hours
export class UpdaterMain {
private doingUpdateCheck = false;
private doingUpdateCheckWithFeedback = false;
private canUpdate = false;
constructor(private main: Main) { }
constructor(private main: Main) {
const linuxCanUpdate = process.platform === 'linux' && isAppImage();
const windowsCanUpdate = process.platform === 'win32' && !isWindowsStore() && !isWindowsPortable();
const macCanUpdate = process.platform === 'darwin' && !isMacAppStore();
this.canUpdate = linuxCanUpdate || windowsCanUpdate || macCanUpdate;
}
async init() {
global.setTimeout(async () => await this.checkForUpdate(), UpdaterCheckInitalDelay);
@ -107,8 +116,7 @@ export class UpdaterMain {
return;
}
if (process.platform === 'linux' && !isAppImage()) {
// Only AppImage packages support auto-update on linux
if (!this.canUpdate) {
if (withFeedback) {
shell.openExternal('https://github.com/bitwarden/desktop/releases');
}

View File

@ -7,5 +7,17 @@ export function isDev() {
}
export function isAppImage() {
return 'APPIMAGE' in process.env;
return process.platform === 'linux' && 'APPIMAGE' in process.env;
}
export function isMacAppStore() {
return process.platform === 'darwin' && process.mas && process.mas === true;
}
export function isWindowsStore() {
return process.platform === 'win32' && process.windowsStore && process.windowsStore === true;
}
export function isWindowsPortable() {
return process.platform === 'win32' && process.env.PORTABLE_EXECUTABLE_DIR != null;
}