Unsubscribe autoUpdater event handlers

This commit is contained in:
Fedor Indutny 2024-04-11 19:47:25 +02:00 committed by GitHub
parent bcaf60a3b2
commit e21cb6e34a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,16 +49,27 @@ export class MacOSUpdater extends Updater {
const { logger } = this;
const { promise, resolve, reject } = explodePromise<void>();
autoUpdater.on('error', (...args) => {
const onError = (...args: Array<unknown>) => {
logger.error('autoUpdater: error', ...args.map(Errors.toLogFormat));
const [error] = args;
cleanup();
reject(error);
});
autoUpdater.on('update-downloaded', () => {
};
const onDownloaded = () => {
logger.info('autoUpdater: update-downloaded event fired');
cleanup();
resolve();
});
};
function cleanup() {
autoUpdater.removeListener('error', onError);
autoUpdater.removeListener('update-downloaded', onDownloaded);
}
autoUpdater.on('error', onError);
autoUpdater.on('update-downloaded', onDownloaded);
// See: https://github.com/electron/electron/issues/5020#issuecomment-477636990
const updateUrl = pathToFileURL(filePath).href;