Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.updateLinux();
} else {
autoUpdater.addListener('update-available', () => {
this.hasUpdate = true;
this.logger.info('New update available');
});
autoUpdater.addListener('update-downloaded', (info) => {
this.notify(info.version);
this.listenUpdate();
});
autoUpdater.addListener('error', (error) => {
this.logger.error(error);
});
autoUpdater.addListener('checking-for-update', () => {
this.logger.info('Checking for update');
});
autoUpdater.addListener('update-not-available', () => {
this.logger.info('No update found');
setTimeout(() => {
autoUpdater.checkForUpdates();
}, 300000);
});
// if (this.platform === 'darwin') {
// autoUpdater.setFeedURL(`https://${CONFIG.UPDATE_SERVER_HOST}/update/darwin?version=${this.currentVersion}`);
// }
autoUpdater.checkForUpdates();
}
setTimeout(() => {
// Auto updater
if (shouldUseSquirrel(isSSB)) {
/* eslint-disable global-require */
const autoUpdater = require('electron-updater').autoUpdater;
/* eslint-enable global-require */
autoUpdater.addListener('update-downloaded', (event, releaseNotes, releaseName) => {
dialog.showMessageBox({
type: 'info',
buttons: ['Yes', 'Cancel'],
defaultId: 1,
title: 'A new update is ready to install',
message: `Version ${releaseName} is downloaded and will be automatically installed. Do you want to quit the app to install it now?`,
}, (response) => {
if (response === 0) {
autoUpdater.quitAndInstall();
}
});
});
autoUpdater.addListener('error', err => log(`Update error: ${err.message}`));
autoUpdater.on('checking-for-update', () => log('Checking for update'));
autoUpdater.on('update-available', () => log('Update available'));
/* eslint-enable global-require */
autoUpdater.addListener('update-downloaded', (event, releaseNotes, releaseName) => {
dialog.showMessageBox({
type: 'info',
buttons: ['Yes', 'Cancel'],
defaultId: 1,
title: 'A new update is ready to install',
message: `Version ${releaseName} is downloaded and will be automatically installed. Do you want to quit the app to install it now?`,
}, (response) => {
if (response === 0) {
autoUpdater.quitAndInstall();
}
});
});
autoUpdater.addListener('error', err => log(`Update error: ${err.message}`));
autoUpdater.on('checking-for-update', () => log('Checking for update'));
autoUpdater.on('update-available', () => log('Update available'));
autoUpdater.on('update-not-available', () => log('No update available'));
autoUpdater.checkForUpdates();
} else {
https.get({
host: 'api.github.com',
path: '/repos/webcatalog/webcatalog/releases/latest',
method: 'GET',
headers: { 'user-agent': `WebCatalog/${app.getVersion()}` },
}, (res) => {
if (res.statusCode >= 200 && res.statusCode <= 299) {
let body = '';
res.on('data', (chunk) => {
body += chunk;
function initialize(getMainWindow, messages) {
if (!messages) {
throw new Error('auto-update initialize needs localized messages');
}
if (autoUpdateDisabled()) {
return;
}
autoUpdater.addListener('update-downloaded', () => {
showUpdateDialog(getMainWindow(), messages);
});
autoUpdater.addListener('error', onError);
checkForUpdates();
setInterval(checkForUpdates, autoUpdaterInterval);
}
ipcMain.addListener('loading-done', () => {
if (process.platform !== 'linux') {
autoUpdater.checkForUpdates();
autoUpdater.addListener('update-available', (info: UpdateInfo) => {
mainWindow!.webContents.send('update-available', info);
autoUpdater.removeAllListeners('update-not-available');
});
ipcMain.addListener('download-update', () => {
autoUpdater.downloadUpdate();
});
ipcMain.addListener('check-for-updates', () => {
autoUpdater.checkForUpdates();
autoUpdater.once('update-not-available', () => {
mainWindow!.webContents.send('update-not-available');
});
});
autoUpdater.signals.progress(progressObj => {
autoUpdater.checkForUpdates();
});
autoUpdater.addListener('update-available', () => {
debug('New update available');
dispatchToRenderer(newVersion());
});
autoUpdater.addListener('update-not-available', () => {
debug('No new updates');
});
autoUpdater.addListener('update-downloaded', () => {
debug('Quitting to install new update');
autoUpdater.quitAndInstall();
return true;
});
autoUpdater.addListener('download-progress', progress => {
debug('Update Progress', progress);
dispatchToRenderer(updateProgress(Math.floor(progress.percent) || 0));
});
autoUpdater.addListener('error', error => {
debug(error);
});
}
ipcMain.addListener('download-update', () => {
autoUpdater.downloadUpdate();
});
ipcMain.addListener('check-for-updates', () => {
autoUpdater.checkForUpdates();
autoUpdater.once('update-not-available', () => {
mainWindow!.webContents.send('update-not-available');
});
});
autoUpdater.signals.progress(progressObj => {
mainWindow!.webContents.send('download-progress', progressObj);
});
autoUpdater.addListener('error', (err: Error) => {
mainWindow!.webContents.send('auto-updater-error', err);
});
autoUpdater.signals.updateDownloaded(() => {
autoUpdater.quitAndInstall();
});
}
});
});
debug('New update available');
dispatchToRenderer(newVersion());
});
autoUpdater.addListener('update-not-available', () => {
debug('No new updates');
});
autoUpdater.addListener('update-downloaded', () => {
debug('Quitting to install new update');
autoUpdater.quitAndInstall();
return true;
});
autoUpdater.addListener('download-progress', progress => {
debug('Update Progress', progress);
dispatchToRenderer(updateProgress(Math.floor(progress.percent) || 0));
});
autoUpdater.addListener('error', error => {
debug(error);
});
}
if (platform === 'linux') {
return;
}
(browserWindow || global.mainWindow).webContents.once('did-finish-load', () => {
autoUpdater.checkForUpdates();
});
autoUpdater.addListener('update-available', () => {
debug('New update available');
dispatchToRenderer(newVersion());
});
autoUpdater.addListener('update-not-available', () => {
debug('No new updates');
});
autoUpdater.addListener('update-downloaded', () => {
debug('Quitting to install new update');
autoUpdater.quitAndInstall();
return true;
});
autoUpdater.addListener('download-progress', progress => {
debug('Update Progress', progress);
dispatchToRenderer(updateProgress(Math.floor(progress.percent) || 0));
});
autoUpdater.addListener('error', error => {
debug(error);
});
}
}
const platform = os.platform();
if (platform === 'linux') {
return;
}
(browserWindow || global.mainWindow).webContents.once('did-finish-load', () => {
autoUpdater.checkForUpdates();
});
autoUpdater.addListener('update-available', () => {
debug('New update available');
dispatchToRenderer(newVersion());
});
autoUpdater.addListener('update-not-available', () => {
debug('No new updates');
});
autoUpdater.addListener('update-downloaded', () => {
debug('Quitting to install new update');
autoUpdater.quitAndInstall();
return true;
});
autoUpdater.addListener('download-progress', progress => {
debug('Update Progress', progress);
dispatchToRenderer(updateProgress(Math.floor(progress.percent) || 0));
});
autoUpdater.addListener('error', error => {
debug(error);
});
}