use readyForUpdates to trigger update from renderer
this is used to only start the updater once the fileserver returned use the latest release
This commit is contained in:
parent
234e9b160e
commit
89757a95a6
|
@ -63,9 +63,7 @@ jobs:
|
|||
- name: Lint Files
|
||||
if: runner.os != 'Windows'
|
||||
run: |
|
||||
yarn format-full
|
||||
yarn eslint
|
||||
yarn tslint
|
||||
yarn lint-full
|
||||
|
||||
- name: Make linux use en_US locale
|
||||
if: runner.os == 'Linux'
|
||||
|
|
|
@ -4,7 +4,6 @@ const process = require('process');
|
|||
const { app } = require('electron');
|
||||
|
||||
const { start } = require('./base_config');
|
||||
const config = require('./config');
|
||||
|
||||
let storageProfile;
|
||||
|
||||
|
@ -16,10 +15,7 @@ const isValidInstance = typeof instance === 'string' && instance.length > 0;
|
|||
const isProduction = environment === 'production' && !isValidInstance;
|
||||
|
||||
// Use seperate data directories for each different environment and app instances
|
||||
// We should prioritise config values first
|
||||
if (config.has(storageProfile)) {
|
||||
storageProfile = config.get('storageProfile');
|
||||
} else if (!isProduction) {
|
||||
if (!isProduction) {
|
||||
storageProfile = environment;
|
||||
if (isValidInstance) {
|
||||
storageProfile = storageProfile.concat(`-${instance}`);
|
||||
|
|
|
@ -1,20 +1,4 @@
|
|||
{
|
||||
"serverUrl": "random.snode",
|
||||
"localUrl": "localhost.loki",
|
||||
"cdnUrl": "random.snode",
|
||||
"contentProxyUrl": "",
|
||||
"seedNodeList": [
|
||||
{
|
||||
"url": "https://storage.seed1.loki.network:4433/"
|
||||
},
|
||||
{
|
||||
"url": "https://storage.seed3.loki.network:4433/"
|
||||
},
|
||||
{
|
||||
"url": "https://public.loki.foundation:4433/"
|
||||
}
|
||||
],
|
||||
"openDevTools": false,
|
||||
"commitHash": "",
|
||||
"import": false
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"seedNodeList": [
|
||||
{
|
||||
"url": "http://public.loki.foundation:38157/"
|
||||
}
|
||||
],
|
||||
"openDevTools": false
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"openDevTools": false
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"openDevTools": true
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"openDevTools": true
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"seedNodeList": [
|
||||
{
|
||||
"url": "http://localhost:22129/"
|
||||
}
|
||||
],
|
||||
"openDevTools": true
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"storageProfile": "test",
|
||||
"openDevTools": false
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"storageProfile": "test",
|
||||
"openDevTools": false
|
||||
}
|
|
@ -386,7 +386,7 @@
|
|||
}
|
||||
|
||||
let connectCount = 0;
|
||||
async function connect(firstRun) {
|
||||
async function connect() {
|
||||
window.log.info('connect');
|
||||
|
||||
// Bootstrap our online/offline detection, only the first time we connect
|
||||
|
@ -400,10 +400,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (firstRun) {
|
||||
window.readyForUpdates();
|
||||
}
|
||||
|
||||
if (!Whisper.Registration.everDone()) {
|
||||
return;
|
||||
}
|
||||
|
|
14
main.js
14
main.js
|
@ -157,17 +157,11 @@ function prepareURL(pathSegments, moreKeys) {
|
|||
locale: locale.name,
|
||||
version: app.getVersion(),
|
||||
commitHash: config.get('commitHash'),
|
||||
serverUrl: config.get('serverUrl'),
|
||||
localUrl: config.get('localUrl'),
|
||||
cdnUrl: config.get('cdnUrl'),
|
||||
// one day explain why we need to do this - neuroscr
|
||||
seedNodeList: JSON.stringify(config.get('seedNodeList')),
|
||||
environment: config.environment,
|
||||
node_version: process.versions.node,
|
||||
hostname: os.hostname(),
|
||||
appInstance: process.env.NODE_APP_INSTANCE,
|
||||
proxyUrl: process.env.HTTPS_PROXY || process.env.https_proxy,
|
||||
contentProxyUrl: config.contentProxyUrl,
|
||||
appStartInitialSpellcheckSetting,
|
||||
...moreKeys,
|
||||
},
|
||||
|
@ -346,7 +340,7 @@ async function createWindow() {
|
|||
|
||||
mainWindow.loadURL(prepareURL([__dirname, 'background.html']));
|
||||
|
||||
if (config.get('openDevTools')) {
|
||||
if ((process.env.NODE_APP_INSTANCE || '').startsWith('devprod')) {
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools({
|
||||
mode: 'bottom',
|
||||
|
@ -414,7 +408,7 @@ ipc.on('set-release-from-file-server', (_event, releaseGotFromFileServer) => {
|
|||
|
||||
let isReadyForUpdates = false;
|
||||
async function readyForUpdates() {
|
||||
console.log('isReadyForUpdates', isReadyForUpdates);
|
||||
console.log('[updater] isReadyForUpdates', isReadyForUpdates);
|
||||
if (isReadyForUpdates) {
|
||||
return;
|
||||
}
|
||||
|
@ -423,6 +417,7 @@ async function readyForUpdates() {
|
|||
|
||||
// Second, start checking for app updates
|
||||
try {
|
||||
// if the user disabled auto updates, this will actually not start the updater
|
||||
await updater.start(getMainWindow, userConfig, locale.messages, logger);
|
||||
} catch (error) {
|
||||
const log = logger || console;
|
||||
|
@ -703,9 +698,6 @@ async function showMainWindow(sqlKey, passwordAttempt = false) {
|
|||
}
|
||||
|
||||
setupMenu();
|
||||
|
||||
// Check updates
|
||||
readyForUpdates();
|
||||
}
|
||||
|
||||
function setupMenu(options) {
|
||||
|
|
22
package.json
22
package.json
|
@ -15,10 +15,8 @@
|
|||
"main": "main.js",
|
||||
"scripts": {
|
||||
"postinstall": "electron-builder install-app-deps && rimraf node_modules/dtrace-provider",
|
||||
"start": "cross-env NODE_APP_INSTANCE=$MULTI electron .",
|
||||
"start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron .",
|
||||
"grunt": "yarn clean-transpile && grunt",
|
||||
"grunt:dev": "yarn clean-transpile; yarn grunt dev --force",
|
||||
"generate": "yarn grunt --force",
|
||||
"build-release": "run-script-os",
|
||||
"build-release-non-linux": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release",
|
||||
|
@ -26,26 +24,20 @@
|
|||
"build-release:macos": "yarn build-release-non-linux",
|
||||
"build-release:linux": "yarn sedtoDeb; yarn build-release-non-linux && yarn sedtoAppImage && yarn build-release-non-linux && yarn sedtoDeb",
|
||||
"build-release-publish": "run-script-os",
|
||||
"build-release-publish-non-linux": "$(yarn bin)/electron-builder --config.extraMetadata.environment=$SIGNAL_ENV --publish=always",
|
||||
"build-release-publish-non-linux": "cross-env SIGNAL_ENV=production $(yarn bin)/electron-builder --config.extraMetadata.environment=$SIGNAL_ENV --publish=always",
|
||||
"build-release-publish:win32": "yarn build-release-publish-non-linux",
|
||||
"build-release-publish:macos": "yarn build-release-publish-non-linux",
|
||||
"build-release-publish:linux": "yarn sedtoDeb; yarn build-release-publish-non-linux && yarn sedtoAppImage && yarn build-release-publish-non-linux && yarn sedtoDeb",
|
||||
"build-module-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",
|
||||
"clean-module-protobuf": "rimraf ts/protobuf/compiled.d.ts ts/protobuf/compiled.js",
|
||||
"build-protobuf": "yarn build-module-protobuf",
|
||||
"clean-protobuf": "yarn clean-module-protobuf",
|
||||
"test": "yarn test-node",
|
||||
"test-node": "mocha --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\" ",
|
||||
"eslint-full": "eslint .",
|
||||
"lint-full": "yarn format-full && yarn lint-files-full",
|
||||
"lint-files-full": "yarn eslint-full && yarn tslint",
|
||||
"tslint": "tslint --format stylish --project .",
|
||||
"appImage": "yarn sedtoAppImage; yarn build-release-non-linux; yarn sedtoDeb",
|
||||
"build-protobuf": "pbjs --target static-module --wrap commonjs --out ts/protobuf/compiled.js protos/*.proto && pbts --out ts/protobuf/compiled.d.ts ts/protobuf/compiled.js --force-long",
|
||||
"test": "mocha --recursive --exit --timeout 10000 \"./ts/test/**/*_test.js\" ",
|
||||
"lint-full": "yarn format-full && eslint . && tslint --format stylish --project .",
|
||||
"format-full": "prettier --list-different --write \"*.{css,js,json,scss,ts,tsx}\" \"./**/*.{css,js,json,scss,ts,tsx}\"",
|
||||
"transpile": "tsc --incremental",
|
||||
"transpile:watch": "yarn grunt --force; tsc -w",
|
||||
"integration-test": "mocha --recursive --exit --timeout 30000 \"./ts/test-integration/**/*.test.js\" \"./ts/test/*.test.js\"",
|
||||
"clean-transpile": "rimraf 'ts/**/*.js' 'ts/*.js' 'ts/*.js.map' 'ts/**/*.js.map' && rimraf tsconfig.tsbuildinfo;",
|
||||
"ready": "yarn clean-transpile; yarn grunt && yarn lint-full && yarn test",
|
||||
"ready": "yarn grunt && yarn lint-full && yarn test",
|
||||
"sedtoAppImage": "sed -i 's/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/\"target\": \"AppImage\"/g' package.json",
|
||||
"sedtoDeb": "sed -i 's/\"target\": \"AppImage\"/\"target\": \\[\"deb\", \"rpm\", \"freebsd\"\\]/g' package.json"
|
||||
},
|
||||
|
@ -65,7 +57,6 @@
|
|||
"color": "^3.1.2",
|
||||
"config": "1.28.1",
|
||||
"country-code-lookup": "^0.0.19",
|
||||
"cross-env": "^6.0.3",
|
||||
"curve25519-js": "^0.0.4",
|
||||
"dompurify": "^2.0.7",
|
||||
"electron-is-dev": "^1.1.0",
|
||||
|
@ -162,6 +153,7 @@
|
|||
"chai": "^4.3.4",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-bytes": "^0.1.2",
|
||||
"cross-env": "^6.0.3",
|
||||
"electron": "^13.6.2",
|
||||
"electron-builder": "22.8.0",
|
||||
"electron-notarize": "^0.2.0",
|
||||
|
|
12
preload.js
12
preload.js
|
@ -211,7 +211,17 @@ window.ReactDOM = require('react-dom');
|
|||
|
||||
window.clipboard = clipboard;
|
||||
|
||||
window.getSeedNodeList = () => JSON.parse(config.seedNodeList);
|
||||
window.getSeedNodeList = () => [
|
||||
{
|
||||
url: 'https://storage.seed1.loki.network:4433/',
|
||||
},
|
||||
{
|
||||
url: 'https://storage.seed3.loki.network:4433/',
|
||||
},
|
||||
{
|
||||
url: 'https://public.loki.foundation:4433/',
|
||||
},
|
||||
];
|
||||
|
||||
const { locale: localFromEnv } = config;
|
||||
window.i18n = i18n.setup(localFromEnv, localeMessages);
|
||||
|
|
|
@ -169,7 +169,7 @@ const cleanUpMediasInterval = DURATION.MINUTES * 60;
|
|||
// every 10 minutes we fetch from the fileserver to check for a new release
|
||||
// * if there is none, no request to github are made.
|
||||
// * if there is a version on the fileserver more recent than our current, we fetch github to get the UpdateInfos and trigger an update as usual (asking user via dialog)
|
||||
const fetchReleaseFromFileServerInterval = DURATION.MINUTES * 10;
|
||||
const fetchReleaseFromFileServerInterval = 1000 * 60; // try to fetch the latest release from the fileserver every minute
|
||||
|
||||
const setupTheme = () => {
|
||||
const theme = window.Events.getThemeSetting();
|
||||
|
@ -274,10 +274,14 @@ const CallContainer = () => {
|
|||
|
||||
async function fetchReleaseFromFSAndUpdateMain() {
|
||||
try {
|
||||
window.log.warn('[updater] about to fetchReleaseFromFSAndUpdateMain');
|
||||
|
||||
const latest = await getLatestDesktopReleaseFileToFsV2();
|
||||
window.log.warn('[updater] fetched latest release from fsv2: ', latest);
|
||||
|
||||
if (isString(latest) && !isEmpty(latest)) {
|
||||
ipcRenderer.send('set-release-from-file-server', latest);
|
||||
window.readyForUpdates();
|
||||
}
|
||||
} catch (e) {
|
||||
window.log.warn(e);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { LoggerType, MessagesType } from './common';
|
|||
import { UserConfig } from '../../app/user_config';
|
||||
|
||||
let initialized = false;
|
||||
let config: UserConfig;
|
||||
let localUserConfig: UserConfig;
|
||||
|
||||
export async function start(
|
||||
getMainWindow: () => BrowserWindow,
|
||||
|
@ -27,16 +27,9 @@ export async function start(
|
|||
throw new Error('updater/start: Must provide logger!');
|
||||
}
|
||||
initialized = true;
|
||||
config = userConfig; // reused below
|
||||
localUserConfig = userConfig; // reused below
|
||||
|
||||
if (autoUpdateDisabled()) {
|
||||
/*
|
||||
If you really want to enable auto-updating in dev mode
|
||||
You need to create a dev-app-update.yml file.
|
||||
A sample can be found in dev-app-update.yml.sample.
|
||||
After that you can change `updatesEnabled` to `true` in the default config.
|
||||
*/
|
||||
|
||||
logger.info('updater/start: Updates disabled - not starting new version checks');
|
||||
|
||||
return;
|
||||
|
@ -54,7 +47,7 @@ export function stop() {
|
|||
|
||||
function autoUpdateDisabled() {
|
||||
// We need to ensure that if auto update is not present in the user config then we assume it is on by default
|
||||
const userSetting = config.get('autoUpdate');
|
||||
const userSetting = localUserConfig.get('autoUpdate');
|
||||
const autoUpdate = typeof userSetting !== 'boolean' || userSetting;
|
||||
|
||||
return (
|
||||
|
|
|
@ -19,10 +19,6 @@ let downloadIgnored = false;
|
|||
let interval: NodeJS.Timeout | undefined;
|
||||
let stopped = false;
|
||||
|
||||
const SECOND = 1000;
|
||||
const MINUTE = SECOND * 60;
|
||||
const INTERVAL = MINUTE * 1;
|
||||
|
||||
export async function start(
|
||||
getMainWindow: () => BrowserWindow,
|
||||
messages: MessagesType,
|
||||
|
@ -45,7 +41,7 @@ export async function start(
|
|||
} catch (error) {
|
||||
logger.error('auto-update: error:', getPrintableError(error));
|
||||
}
|
||||
}, INTERVAL);
|
||||
}, 1000 * 60 * 10); // trigger and try to update every 10 minutes to let the file gets downloaded if we are updating
|
||||
stopped = false;
|
||||
|
||||
await checkForUpdates(getMainWindow, messages, logger);
|
||||
|
@ -64,17 +60,19 @@ async function checkForUpdates(
|
|||
messages: MessagesType,
|
||||
logger: LoggerType
|
||||
) {
|
||||
logger.info('[updater] checkForUpdates');
|
||||
if (stopped || isUpdating || downloadIgnored) {
|
||||
return;
|
||||
}
|
||||
|
||||
const canUpdate = await canAutoUpdate();
|
||||
logger.info('[updater] canUpdate', canUpdate);
|
||||
if (!canUpdate) {
|
||||
logger.info('checkForUpdates canAutoUpdate false');
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('auto-update: checkForUpdates...');
|
||||
logger.info('[updater] checkForUpdates...');
|
||||
|
||||
isUpdating = true;
|
||||
|
||||
|
@ -83,17 +81,17 @@ async function checkForUpdates(
|
|||
? ((getMainWindow() as any).getLatestDesktopRelease() as string | undefined)
|
||||
: undefined;
|
||||
|
||||
logger.info('checkForUpdates latestVersionFromFsFromRenderer', latestVersionFromFsFromRenderer);
|
||||
logger.info('[updater] latestVersionFromFsFromRenderer', latestVersionFromFsFromRenderer);
|
||||
if (!latestVersionFromFsFromRenderer || !latestVersionFromFsFromRenderer?.length) {
|
||||
logger.info(
|
||||
'testVersionFromFsFromRenderer was not updated yet by renderer. Skipping update check'
|
||||
'[updater] testVersionFromFsFromRenderer was not updated yet by renderer. Skipping update check'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const currentVersion = autoUpdater.currentVersion.toString();
|
||||
const isMoreRecent = isVersionGreaterThan(latestVersionFromFsFromRenderer, currentVersion);
|
||||
logger.info('checkForUpdates isMoreRecent', isMoreRecent);
|
||||
logger.info('[updater] checkForUpdates isMoreRecent', isMoreRecent);
|
||||
if (!isMoreRecent) {
|
||||
logger.info(
|
||||
`Fileserver has no update so we are not looking for an update from github current:${currentVersion} fromFileServer:${latestVersionFromFsFromRenderer}`
|
||||
|
@ -104,27 +102,27 @@ async function checkForUpdates(
|
|||
// Get the update using electron-updater, this fetches from github
|
||||
const result = await autoUpdater.checkForUpdates();
|
||||
|
||||
logger.info('checkForUpdates github fetch result:', result);
|
||||
logger.info('[updater] checkForUpdates got github response back ');
|
||||
|
||||
if (!result.updateInfo) {
|
||||
logger.info('auto-update: no update info received');
|
||||
logger.info('[updater] no update info received');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const hasUpdate = isUpdateAvailable(result.updateInfo);
|
||||
logger.info('checkForUpdates hasUpdate:', hasUpdate);
|
||||
logger.info('[updater] hasUpdate:', hasUpdate);
|
||||
|
||||
if (!hasUpdate) {
|
||||
logger.info('auto-update: no update available');
|
||||
logger.info('[updater] no update available');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('auto-update: showing download dialog...');
|
||||
logger.info('[updater] showing download dialog...');
|
||||
const shouldDownload = await showDownloadUpdateDialog(getMainWindow(), messages);
|
||||
logger.info('checkForUpdates shouldDownload:', shouldDownload);
|
||||
logger.info('[updater] shouldDownload:', shouldDownload);
|
||||
|
||||
if (!shouldDownload) {
|
||||
downloadIgnored = true;
|
||||
|
@ -139,13 +137,13 @@ async function checkForUpdates(
|
|||
}
|
||||
|
||||
// Update downloaded successfully, we should ask the user to update
|
||||
logger.info('auto-update: showing update dialog...');
|
||||
logger.info('[updater] showing update dialog...');
|
||||
const shouldUpdate = await showUpdateDialog(getMainWindow(), messages);
|
||||
if (!shouldUpdate) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info('auto-update: calling quitAndInstall...');
|
||||
logger.info('[updater] calling quitAndInstall...');
|
||||
markShouldQuit();
|
||||
autoUpdater.quitAndInstall();
|
||||
} finally {
|
||||
|
|
|
@ -59,6 +59,7 @@ declare global {
|
|||
userConfig: any;
|
||||
versionInfo: any;
|
||||
getConversations: () => ConversationCollection;
|
||||
readyForUpdates: () => void;
|
||||
MediaRecorder: any;
|
||||
|
||||
contextMenuShown: boolean;
|
||||
|
|
Loading…
Reference in New Issue