From acf7bf1f64d00c1911ee4c33ffd7963a68e0a724 Mon Sep 17 00:00:00 2001 From: Paul Sori Date: Fri, 25 Oct 2019 01:43:47 -0400 Subject: [PATCH] auto updates fully debugged --- mstream-electron.js | 76 ++++++++++++--------------------------------- package.json | 2 +- 2 files changed, 21 insertions(+), 57 deletions(-) diff --git a/mstream-electron.js b/mstream-electron.js index 74fd1a1..0593b39 100644 --- a/mstream-electron.js +++ b/mstream-electron.js @@ -146,7 +146,7 @@ function bootServer(program) { }, { label: 'Check For Updates', click: function () { - autoUpdater.checkForUpdates(); + autoUpdater.checkForUpdatesAndNotify(); } }, { type: 'separator' }, @@ -202,66 +202,30 @@ function bootServer(program) { // TODO: Try booting server in forked thread instead. Might give some speed improvements server = require('./mstream.js'); server.serveIt(program); - - setInterval(() => { autoUpdater.checkForUpdates(); }, 86400000); - checkForUpdates(); } -async function checkForUpdates() { - try { - await autoUpdater.checkForUpdates(); - } catch(err) { - console.log(err); - } -} - -// Handle Auto Updates -autoUpdater.on('checking-for-update', () => { - if (!trayTemplate) { return; } - - trayTemplate[1].label = { - label: 'Checking For Updates...', click: function () { } - } -}) autoUpdater.on('update-available', (info) => { if (!trayTemplate) { return; } trayTemplate[1] = { - label: 'Downloading Update (0%)', click: function () { } - } -}); -autoUpdater.on('update-not-available', (info) => { - if (!trayTemplate) { return; } - - trayTemplate[1] = { - label: 'Check For Updates', click: function () { - autoUpdater.checkForUpdates(); - } - } -}); -autoUpdater.on('error', (err) => { - if (!trayTemplate) { return; } - - console.log(err); - trayTemplate[1] = { - label: 'Update Error. Try Again', click: function () { - autoUpdater.checkForUpdates(); - } - } -}); -autoUpdater.on('download-progress', (progressObj) => { - if (!trayTemplate) { return; } - - trayTemplate[1] = { - label: `Downloading Update (${progressObj.percent}%)`, click: function () { } - } -}) -autoUpdater.on('update-downloaded', (info) => { - if (!trayTemplate) { return; } - - trayTemplate[1] = { - label: 'Update Downloaded - Click to install', click: function () { - autoUpdater.quitAndInstall(); + label: 'Update Ready: Quit And Install', click: function () { + autoUpdater.quitAndInstall(); } }; -}) + + trayTemplate[4] = { + label: 'Restart and Reconfigure', click: function () { + fs.writeFileSync(fe.join(app.getPath('userData'), 'save/temp-boot-disable.json'), JSON.stringify({ disable: true }), 'utf8'); + app.isQuiting = true; + autoUpdater.quitAndInstall(); + } + }; + + trayTemplate[7] = { + label: 'Quit', click: function () { + autoUpdater.quitAndInstall(); + } + }; + + appIcon.setContextMenu(Menu.buildFromTemplate(trayTemplate)); +}); \ No newline at end of file diff --git a/package.json b/package.json index 2728987..45f9075 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mstream", - "version": "4.4.6", + "version": "4.5.0", "description": "music streaming server", "main": "cli-boot-wrapper.js", "bin": {