1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Electron: Better error handling for auto-update

This commit is contained in:
Laurent Cozic 2017-11-21 18:59:32 +00:00
parent 3722012da5
commit b0b5488c2e
2 changed files with 12 additions and 8 deletions

View File

@ -8,7 +8,6 @@ const { BaseModel } = require('lib/base-model.js');
const { _, setLocale } = require('lib/locale.js');
const os = require('os');
const fs = require('fs-extra');
const { Logger } = require('lib/logger.js');
const { Tag } = require('lib/models/tag.js');
const { reg } = require('lib/registry.js');
const { sprintf } = require('sprintf-js');

View File

@ -5,6 +5,7 @@ class Bridge {
constructor(electronWrapper) {
this.electronWrapper_ = electronWrapper;
this.autoUpdateLogger_ = null;
}
electronApp() {
@ -78,17 +79,21 @@ class Bridge {
return require('electron').shell.openItem(fullPath)
}
checkForUpdatesAndNotify(logFilePath) {
async checkForUpdatesAndNotify(logFilePath) {
if (!this.autoUpdater_) {
const logger = new Logger();
logger.addTarget('file', { path: logFilePath });
logger.setLevel(Logger.LEVEL_DEBUG);
logger.info('checkForUpdatesAndNotify: Intializing...');
this.autoUpdateLogger_ = new Logger();
this.autoUpdateLogger_.addTarget('file', { path: logFilePath });
this.autoUpdateLogger_.setLevel(Logger.LEVEL_DEBUG);
this.autoUpdateLogger_.info('checkForUpdatesAndNotify: Intializing...');
this.autoUpdater_ = require("electron-updater").autoUpdater;
this.autoUpdater_.logger = logger;
this.autoUpdater_.logger = this.autoUpdateLogger_;
}
return this.autoUpdater_.checkForUpdatesAndNotify();
try {
await this.autoUpdater_.checkForUpdatesAndNotify();
} catch (error) {
this.autoUpdateLogger_.error(error);
}
}
}