Electron autoupdater progress bar

Pirozek picture Pirozek · Jan 10, 2017 · Viewed 8.1k times · Source

is there any way to set up a progress bar for downloading new update of app in Electron? I am developing app for Windows using Squirrel and electron-simple-updater and my problem is that updater only gives out events when it starts to download update and when it finishes. My update is kinda large (around 80MB) and for users with slow ISPs it kinda sux :(

Answer

Darshan Jain picture Darshan Jain · Feb 5, 2019
const log = require('electron-log');
const { autoUpdater } = require("electron-updater");
autoUpdater.logger = log;
log.info('App starting...');    
autoUpdater.on('download-progress', (progressObj) => {
    let log_message = "Download speed: " + progressObj.bytesPerSecond;
    log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
    log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
    sendStatusToWindow(log_message);
})

function sendStatusToWindow(text) {
    log.info(text);
    homePageWindow.webContents.send('message', text);
}

With this code the log can be seen to see the progress of the download