From b10c22086edc6a79b22e9ed82a29b8a218db86da Mon Sep 17 00:00:00 2001 From: openbuilds-engineer Date: Thu, 27 Dec 2018 15:16:39 +0200 Subject: [PATCH] Fix for #36 - Check if not already downloading before starting download --- index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index bbbb4d8..b9b917b 100644 --- a/index.js +++ b/index.js @@ -65,6 +65,7 @@ var appIcon = null, mainWindow = null var autoUpdater +var updateIsDownloading = false; if (isElectron()) { autoUpdater = require("electron-updater").autoUpdater var availversion = '0.0.0' @@ -85,6 +86,7 @@ if (isElectron()) { } }) autoUpdater.on('update-available', (ev, info) => { + updateIsDownloading = true; var string = "Starting Download: v" + ev.version; availversion = ev.version var output = { @@ -140,6 +142,7 @@ if (isElectron()) { } }) autoUpdater.on('download-progress', (ev, progressObj) => { + updateIsDownloading = true; var string = 'Download update ... ' + ev.percent.toFixed(1) + '%'; console.log(string) var output = { @@ -179,6 +182,7 @@ if (isElectron()) { }) // Launch Gui to run Update } + updateIsDownloading = false; }); // Schedule AutoUpdater to run from Tray @@ -630,10 +634,12 @@ io.on("connection", function(socket) { }) socket.on("downloadUpdate", function(data) { - if (typeof autoUpdater !== 'undefined') { - autoUpdater.checkForUpdates(); - } else { - console.log("autoUpdater not found") + if (!updateIsDownloading) { + if (typeof autoUpdater !== 'undefined') { + autoUpdater.checkForUpdates(); + } else { + console.log("autoUpdater not found") + } } })