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", "message": "Debug Log",
"description": "View menu item to open the debug log (title case)" "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": { "helpMenuShowKeyboardShortcuts": {
"message": "Show Keyboard Shortcuts", "message": "Show Keyboard Shortcuts",
"description": "Item under the help menu, pops up a screen showing the application's 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; openSupportPage: () => unknown;
setupAsNewDevice: () => unknown; setupAsNewDevice: () => unknown;
setupAsStandalone: () => unknown; setupAsStandalone: () => unknown;
forceUpdate: () => unknown;
showAbout: () => unknown; showAbout: () => unknown;
showDebugLog: () => unknown; showDebugLog: () => unknown;
showKeyboardShortcuts: () => unknown; showKeyboardShortcuts: () => unknown;
@ -52,6 +53,7 @@ export const createTemplate = (
platform, platform,
setupAsNewDevice, setupAsNewDevice,
setupAsStandalone, setupAsStandalone,
forceUpdate,
showAbout, showAbout,
showDebugLog, showDebugLog,
showKeyboardShortcuts, 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); ipc.once('ready-for-updates', readyForUpdates);
const TEN_MINUTES = 10 * 60 * 1000; const TEN_MINUTES = 10 * 60 * 1000;
@ -1404,6 +1416,7 @@ function setupMenu(options) {
platform, platform,
setupAsNewDevice, setupAsNewDevice,
setupAsStandalone, setupAsStandalone,
forceUpdate,
}; };
const template = createTemplate(menuOptions, locale.messages); const template = createTemplate(menuOptions, locale.messages);
const menu = Menu.buildFromTemplate(template); const menu = Menu.buildFromTemplate(template);

View File

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

View File

@ -154,6 +154,10 @@
{ {
"label": "Toggle Developer Tools", "label": "Toggle Developer Tools",
"role": "toggleDevTools" "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', label: 'Windows',
platform: 'win32', platform: 'win32',
fixtures: { fixtures: {
default: './fixtures/menu-windows-linux', default: './fixtures/menu-windows',
setup: './fixtures/menu-windows-linux-setup', setup: './fixtures/menu-windows-setup',
}, },
}, },
{ {
label: 'Linux', label: 'Linux',
platform: 'linux', platform: 'linux',
fixtures: { fixtures: {
default: './fixtures/menu-windows-linux', default: './fixtures/menu-linux',
setup: './fixtures/menu-windows-linux-setup', setup: './fixtures/menu-linux-setup',
}, },
}, },
]; ];
@ -60,6 +60,7 @@ describe('SignalMenu', () => {
includeSetup, includeSetup,
setupAsNewDevice: null, setupAsNewDevice: null,
setupAsStandalone: null, setupAsStandalone: null,
forceUpdate: null,
showAbout: null, showAbout: null,
showDebugLog: null, showDebugLog: null,
showKeyboardShortcuts: null, showKeyboardShortcuts: null,

View File

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

View File

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

View File

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

View File

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