Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}).on('click-install', () => {
updaterModal.webContents.send('start-download');
autoUpdater.signals.progress((data) => { // eslint-disable-line max-nested-callbacks
updaterModal.send('progress', Math.floor(data.percent));
console.log('progress:', data);
});
cancellationToken = new CancellationToken();
downloadAndInstall(cancellationToken);
}).on('click-download', () => {
shell.openExternal('https://about.mattermost.com/download/#mattermostApps');
log.info("checking for update")
})
autoUpdater.on("update-available", (info: string) => {
log.info("update available")
})
autoUpdater.on("update-not-available", (info: string) => {
log.info("update not available")
})
autoUpdater.on("error", (err: Error) => {
log.error("error updating", err.message)
})
autoUpdater.signals.progress(info => {
log.info(`${info.percent}%`)
})
// fires when an update has been downloaded
autoUpdater.signals.updateDownloaded(info => {
log.info("update downloaded")
autoUpdater.quitAndInstall()
})
}
})
autoUpdater.on("update-not-available", (info: string) => {
log.info("update not available")
})
autoUpdater.on("error", (err: Error) => {
log.error("error updating", err.message)
})
autoUpdater.signals.progress(info => {
log.info(`${info.percent}%`)
})
// fires when an update has been downloaded
autoUpdater.signals.updateDownloaded(info => {
log.info("update downloaded")
autoUpdater.quitAndInstall()
})
}
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();
});
}
});
});
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 => {
mainWindow!.webContents.send('download-progress', progressObj);
});
autoUpdater.addListener('error', (err: Error) => {
mainWindow!.webContents.send('auto-updater-error', err);
});
autoUpdater.signals.updateDownloaded(() => {
autoUpdater.quitAndInstall();
});
}
});
});
public async loaderReady() {
if (!isProduction()) {
this.windowsHandler.sendToLoader('no-update-found');
return;
}
logger.info('Server', 'Checking for updates.');
autoUpdater.allowPrerelease = true;
autoUpdater.signals.progress((progress: ProgressInfo) => {
this.windowsHandler.sendToLoader('update-progress', Math.round(progress.percent));
});
autoUpdater.signals.updateDownloaded(() => {
autoUpdater.quitAndInstall(true, true);
});
try {
const lastUpdate: UpdateCheckResult = await autoUpdater.checkForUpdates();
if (compareVersion(lastUpdate.updateInfo.version, autoUpdater.currentVersion.version) === 1) {
logger.info('Server', `Update ${lastUpdate.updateInfo.version} found.`);
this.windowsHandler.sendToLoader('update-found', lastUpdate.updateInfo.version);
} else {
logger.info('Server', 'No updates found.');
this.windowsHandler.sendToLoader('no-update-found');
}
} catch (error) {
logger.info('Server', 'Internet is offline, aborting updates checking.');
constructor() {
const platform = os.platform();
if (platform === 'linux' || isDev) {
return;
}
const log = require('electron-log')
log.transports.file.level = 'info';
autoUpdater.logger = log;
autoUpdater.signals.updateDownloaded(it => {
notify('A new update is ready to install', `Version ${it.version} is downloaded and will be automatically installed on Quit`)
});
autoUpdater.checkForUpdates();
}
}
public async loaderReady() {
if (!isProduction()) {
this.windowsHandler.sendToLoader('no-update-found');
return;
}
logger.info('Server', 'Checking for updates.');
autoUpdater.allowPrerelease = true;
autoUpdater.signals.progress((progress: ProgressInfo) => {
this.windowsHandler.sendToLoader('update-progress', Math.round(progress.percent));
});
autoUpdater.signals.updateDownloaded(() => {
autoUpdater.quitAndInstall(true, true);
});
try {
const lastUpdate: UpdateCheckResult = await autoUpdater.checkForUpdates();
if (compareVersion(lastUpdate.updateInfo.version, autoUpdater.currentVersion.version) === 1) {
logger.info('Server', `Update ${lastUpdate.updateInfo.version} found.`);
this.windowsHandler.sendToLoader('update-found', lastUpdate.updateInfo.version);
} else {
logger.info('Server', 'No updates found.');
this.windowsHandler.sendToLoader('no-update-found');
}
} catch (error) {
logger.info('Server', 'Internet is offline, aborting updates checking.');
this.windowsHandler.sendToLoader('no-update-found');
}
}
constructor() {
if (isDev) {
return;
}
const platform = os.platform();
if (platform === "linux") {
return;
}
autoUpdater.logger = console;
autoUpdater.signals.updateDownloaded(it => {
notify("A new update is ready to install", `Version ${it.version} is downloaded and will be automatically installed on Quit`);
});
autoUpdater.checkForUpdates();
}
}
constructor() {
if (isDev()) {
return
}
const platform = os.platform()
if (platform === "linux") {
return
}
const log = require("electron-log")
log.transports.file.level = "info"
autoUpdater.logger = log
autoUpdater.signals.updateDownloaded(versionInfo => {
const dialogOptions = {
type: "question",
defaultId: 0,
message: `The update is ready to install, Version ${versionInfo.version} has been downloaded and will be automatically installed when you click OK`
}
let focusedWindow = BrowserWindow.getFocusedWindow()
BrowserWindow.getAllWindows()
dialog.showMessageBox(focusedWindow, dialogOptions, function () {
setImmediate(() => {
app.removeAllListeners("window-all-closed")
if (focusedWindow != null) {
focusedWindow.close()
}
autoUpdater.quitAndInstall(false)
})