Updater debug utility

This commit is contained in:
Fedor Indutny 2021-06-30 14:27:18 -07:00 committed by GitHub
parent e7e9021e3f
commit 759ced3417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 409 additions and 15 deletions

View File

@ -663,6 +663,10 @@
"message": "Debug Log",
"description": "View menu item to open the debug log (title case)"
},
"forceUpdate": {
"message": "Force Update",
"description": "View menu item to force the app to update download and install"
},
"helpMenuShowKeyboardShortcuts": {
"message": "Show Keyboard Shortcuts",
"description": "Item under the help menu, pops up a screen showing the application's keyboard shortcuts"

View File

@ -24,6 +24,7 @@ type OptionsType = {
openSupportPage: () => unknown;
setupAsNewDevice: () => unknown;
setupAsStandalone: () => unknown;
forceUpdate: () => unknown;
showAbout: () => unknown;
showDebugLog: () => unknown;
showKeyboardShortcuts: () => unknown;
@ -52,6 +53,7 @@ export const createTemplate = (
platform,
setupAsNewDevice,
setupAsStandalone,
forceUpdate,
showAbout,
showDebugLog,
showKeyboardShortcuts,
@ -162,6 +164,14 @@ export const createTemplate = (
},
]
: []),
...(devTools && platform !== 'linux'
? [
{
label: messages.forceUpdate.message,
click: forceUpdate,
},
]
: []),
],
},
{

13
main.js
View File

@ -666,6 +666,18 @@ async function readyForUpdates() {
}
}
async function forceUpdate() {
try {
logger.info('starting force update');
await updater.force();
} catch (error) {
logger.error(
'Error during force update:',
error && error.stack ? error.stack : error
);
}
}
ipc.once('ready-for-updates', readyForUpdates);
const TEN_MINUTES = 10 * 60 * 1000;
@ -1404,6 +1416,7 @@ function setupMenu(options) {
platform,
setupAsNewDevice,
setupAsStandalone,
forceUpdate,
};
const template = createTemplate(menuOptions, locale.messages);
const menu = Menu.buildFromTemplate(template);

View File

@ -161,6 +161,10 @@
{
"label": "Toggle Developer Tools",
"role": "toggleDevTools"
},
{
"label": "Force Update",
"click": null
}
]
},

View File

@ -154,6 +154,10 @@
{
"label": "Toggle Developer Tools",
"role": "toggleDevTools"
},
{
"label": "Force Update",
"click": null
}
]
},

View File

@ -0,0 +1,164 @@
[
{
"label": "&File",
"submenu": [
{
"label": "Set Up as New Device",
"click": null
},
{
"type": "separator"
},
{
"label": "Create/upload sticker pack",
"click": null
},
{
"accelerator": "CommandOrControl+,",
"label": "Preferences…",
"click": null
},
{
"type": "separator"
},
{
"label": "Quit Signal",
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteAndMatchStyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select All",
"role": "selectAll"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetZoom"
},
{
"accelerator": "Control+=",
"label": "Zoom In",
"role": "zoomIn"
},
{
"label": "Zoom Out",
"role": "zoomOut"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggleDevTools"
},
{
"label": "Force Update",
"click": null
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Minimize",
"role": "minimize"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Show Keyboard Shortcuts",
"accelerator": "CmdOrCtrl+/",
"click": null
},
{
"type": "separator"
},
{
"label": "Contact Us",
"click": null
},
{
"label": "Go to Release Notes",
"click": null
},
{
"label": "Go to Forums",
"click": null
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Join the Beta",
"click": null
},
{
"type": "separator"
},
{
"label": "About Signal Desktop",
"click": null
}
]
}
]

View File

@ -0,0 +1,157 @@
[
{
"label": "&File",
"submenu": [
{
"label": "Create/upload sticker pack",
"click": null
},
{
"accelerator": "CommandOrControl+,",
"label": "Preferences…",
"click": null
},
{
"type": "separator"
},
{
"label": "Quit Signal",
"role": "quit"
}
]
},
{
"label": "&Edit",
"submenu": [
{
"label": "Undo",
"role": "undo"
},
{
"label": "Redo",
"role": "redo"
},
{
"type": "separator"
},
{
"label": "Cut",
"role": "cut"
},
{
"label": "Copy",
"role": "copy"
},
{
"label": "Paste",
"role": "paste"
},
{
"label": "Paste and Match Style",
"role": "pasteAndMatchStyle"
},
{
"label": "Delete",
"role": "delete"
},
{
"label": "Select All",
"role": "selectAll"
}
]
},
{
"label": "&View",
"submenu": [
{
"label": "Actual Size",
"role": "resetZoom"
},
{
"accelerator": "Control+=",
"label": "Zoom In",
"role": "zoomIn"
},
{
"label": "Zoom Out",
"role": "zoomOut"
},
{
"type": "separator"
},
{
"label": "Toggle Full Screen",
"role": "togglefullscreen"
},
{
"type": "separator"
},
{
"label": "Debug Log",
"click": null
},
{
"type": "separator"
},
{
"label": "Toggle Developer Tools",
"role": "toggleDevTools"
},
{
"label": "Force Update",
"click": null
}
]
},
{
"label": "&Window",
"role": "window",
"submenu": [
{
"label": "Minimize",
"role": "minimize"
}
]
},
{
"label": "&Help",
"role": "help",
"submenu": [
{
"label": "Show Keyboard Shortcuts",
"accelerator": "CmdOrCtrl+/",
"click": null
},
{
"type": "separator"
},
{
"label": "Contact Us",
"click": null
},
{
"label": "Go to Release Notes",
"click": null
},
{
"label": "Go to Forums",
"click": null
},
{
"label": "Go to Support Page",
"click": null
},
{
"label": "Join the Beta",
"click": null
},
{
"type": "separator"
},
{
"label": "About Signal Desktop",
"click": null
}
]
}
]

View File

@ -19,16 +19,16 @@ const PLATFORMS = [
label: 'Windows',
platform: 'win32',
fixtures: {
default: './fixtures/menu-windows-linux',
setup: './fixtures/menu-windows-linux-setup',
default: './fixtures/menu-windows',
setup: './fixtures/menu-windows-setup',
},
},
{
label: 'Linux',
platform: 'linux',
fixtures: {
default: './fixtures/menu-windows-linux',
setup: './fixtures/menu-windows-linux-setup',
default: './fixtures/menu-linux',
setup: './fixtures/menu-linux-setup',
},
},
];
@ -60,6 +60,7 @@ describe('SignalMenu', () => {
includeSetup,
setupAsNewDevice: null,
setupAsStandalone: null,
forceUpdate: null,
showAbout: null,
showDebugLog: null,
showKeyboardShortcuts: null,

View File

@ -40,8 +40,13 @@ const { platform } = process;
export const ACK_RENDER_TIMEOUT = 10000;
export type UpdaterInterface = {
force(): Promise<void>;
};
export async function checkForUpdates(
logger: LoggerType
logger: LoggerType,
forceUpdate = false
): Promise<{
fileName: string;
version: string;
@ -55,8 +60,11 @@ export async function checkForUpdates(
return null;
}
if (isVersionNewer(version)) {
logger.info(`checkForUpdates: found newer version ${version}`);
if (forceUpdate || isVersionNewer(version)) {
logger.info(
`checkForUpdates: found newer version ${version} ` +
`forceUpdate=${forceUpdate}`
);
return {
fileName: getUpdateFileName(yaml),

View File

@ -4,6 +4,7 @@
import { get as getFromConfig } from 'config';
import { BrowserWindow } from 'electron';
import { UpdaterInterface } from './common';
import { start as startMacOS } from './macos';
import { start as startWindows } from './windows';
import { LocaleType } from '../types/I18N';
@ -11,6 +12,8 @@ import { LoggerType } from '../types/Logging';
let initialized = false;
let updater: UpdaterInterface | undefined;
export async function start(
getMainWindow: () => BrowserWindow,
locale?: LocaleType,
@ -39,14 +42,24 @@ export async function start(
}
if (platform === 'win32') {
await startWindows(getMainWindow, locale, logger);
updater = await startWindows(getMainWindow, locale, logger);
} else if (platform === 'darwin') {
await startMacOS(getMainWindow, locale, logger);
updater = await startMacOS(getMainWindow, locale, logger);
} else {
throw new Error('updater/start: Unsupported platform');
}
}
export async function force(): Promise<void> {
if (!initialized) {
throw new Error("updater/force: Updates haven't been initialized!");
}
if (updater) {
await updater.force();
}
}
function autoUpdateDisabled() {
return (
process.platform === 'linux' ||

View File

@ -21,6 +21,7 @@ import {
setUpdateListener,
showCannotUpdateDialog,
showUpdateDialog,
UpdaterInterface,
} from './common';
import { LocaleType } from '../types/I18N';
import { LoggerType } from '../types/Logging';
@ -36,7 +37,7 @@ export async function start(
getMainWindow: () => BrowserWindow,
locale: LocaleType,
logger: LoggerType
): Promise<void> {
): Promise<UpdaterInterface> {
logger.info('macos/start: starting checks...');
loggerForQuitHandler = logger;
@ -53,6 +54,12 @@ export async function start(
setUpdateListener(createUpdater(logger));
await checkDownloadAndInstall(getMainWindow, locale, logger);
return {
async force(): Promise<void> {
return checkDownloadAndInstall(getMainWindow, locale, logger, true);
},
};
}
let fileName: string;
@ -63,11 +70,12 @@ let loggerForQuitHandler: LoggerType;
async function checkDownloadAndInstall(
getMainWindow: () => BrowserWindow,
locale: LocaleType,
logger: LoggerType
logger: LoggerType,
force = false
) {
logger.info('checkDownloadAndInstall: checking for update...');
try {
const result = await checkForUpdates(logger);
const result = await checkForUpdates(logger, force);
if (!result) {
return;
}

View File

@ -18,6 +18,7 @@ import {
setUpdateListener,
showCannotUpdateDialog,
showUpdateDialog,
UpdaterInterface,
} from './common';
import { LocaleType } from '../types/I18N';
import { LoggerType } from '../types/Logging';
@ -41,7 +42,7 @@ export async function start(
getMainWindow: () => BrowserWindow,
locale: LocaleType,
logger: LoggerType
): Promise<void> {
): Promise<UpdaterInterface> {
logger.info('windows/start: starting checks...');
loggerForQuitHandler = logger;
@ -59,16 +60,23 @@ export async function start(
await deletePreviousInstallers(logger);
await checkDownloadAndInstall(getMainWindow, locale, logger);
return {
async force(): Promise<void> {
return checkDownloadAndInstall(getMainWindow, locale, logger, true);
},
};
}
async function checkDownloadAndInstall(
getMainWindow: () => BrowserWindow,
locale: LocaleType,
logger: LoggerType
logger: LoggerType,
force = false
) {
try {
logger.info('checkDownloadAndInstall: checking for update...');
const result = await checkForUpdates(logger);
const result = await checkForUpdates(logger, force);
if (!result) {
return;
}