A full-featured download manager.
fix: auto update exception
Dr_rOotc6a9eb226d46
diff --git a/src/main/Application.js b/src/main/Application.jsindex 829fa5d4..2c0d256f 100644--- a/src/main/Application.js+++ b/src/main/Application.js@@ -557,8 +557,9 @@ export default class Application extends EventEmitter {win.setProgressBar(0)})- this.updateManager.on('will-updated', (event) => {+ this.updateManager.on('will-updated', async (event) => {this.windowManager.setWillQuit(true)+ await this.stop()})this.updateManager.on('update-error', (event) => {diff --git a/src/main/core/UpdateManager.js b/src/main/core/UpdateManager.jsindex d07664d5..75dd8ca7 100644--- a/src/main/core/UpdateManager.js+++ b/src/main/core/UpdateManager.js@@ -17,8 +17,10 @@ export default class UpdateManager extends EventEmitter {this.options = optionsthis.i18n = getI18n()+ this.isChecking = falsethis.updater = autoUpdaterthis.updater.autoDownload = false+ this.updater.autoInstallOnAppQuit = falsethis.updater.logger = loggerthis.autoCheckData = {checkEnable: this.options.autoCheck,@@ -40,9 +42,10 @@ export default class UpdateManager extends EventEmitter {this.updater.on('update-not-available', this.updateNotAvailable.bind(this))this.updater.on('download-progress', this.updateDownloadProgress.bind(this))this.updater.on('update-downloaded', this.updateDownloaded.bind(this))+ this.updater.on('update-cancelled', this.updateCancelled.bind(this))this.updater.on('error', this.updateError.bind(this))- if (this.autoCheckData.checkEnable) {+ if (this.autoCheckData.checkEnable && !this.isChecking) {this.autoCheckData.userCheck = falsethis.updater.checkForUpdates()}@@ -54,6 +57,7 @@ export default class UpdateManager extends EventEmitter {}checkingForUpdate () {+ this.isChecking = truethis.emit('checking')}@@ -73,6 +77,7 @@ export default class UpdateManager extends EventEmitter {}updateNotAvailable (event, info) {+ this.isChecking = falsethis.emit('update-not-available', info)if (this.autoCheckData.userCheck) {dialog.showMessageBox({@@ -102,20 +107,26 @@ export default class UpdateManager extends EventEmitter {title: this.i18n.t('app.check-for-updates-title'),message: this.i18n.t('app.update-downloaded-message')}).then(_ => {+ this.isChecking = falsethis.emit('will-updated')- setImmediate(() => {+ setTimeout(() => {this.updater.quitAndInstall()- })+ }, 200)})}+ updateCancelled () {+ this.isChecking = false+ }+updateError (event, error) {+ this.isChecking = falsethis.emit('update-error', error)const msg = (error == null)- ? this.i18n.t('update-error-message')+ ? this.i18n.t('app.update-error-message'): (error.stack || error).toString()this.updater.logger.warn(`[Motrix] update-error: ${msg}`)- dialog.showErrorBox(msg)+ dialog.showErrorBox('Error', msg)}}