9

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 :(

Pirozek
  • 1,250
  • 4
  • 16
  • 25
  • 1
    Looking for the same, google is not helping ... – GWorking May 04 '17 at 06:22
  • Same here...the 'download-progress' is not fired using electron-simple-updater. Did you manage to find a workaround? – MarBVI Sep 13 '17 at 15:35
  • @MarBVI nope, I am stuck here. Its really bad that if you need this simple thing you have to do all the work yourself meaning building your own updater. Thats where maybe I will end up, because there seems to be no viable solutions for this problem :( – Pirozek Sep 14 '17 at 06:32
  • Actually I'm not even able to download the update. I'm getting an error "Cannot find Squirrel". I'm also using electrin-simple-updater and creating my .exe with electron-builder. Any help you can give me? – MarBVI Sep 14 '17 at 11:58

2 Answers2

6
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

Vaibhav Vishal
  • 6,576
  • 7
  • 27
  • 48
Darshan Jain
  • 781
  • 9
  • 19
4

Maybe this link gives what you want

https://github.com/iffy/electron-updater-example/blob/master/main.js

autoUpdater.on('download-progress', (ev, progressObj) => {
  sendStatusToWindow('Download progress...');
})
GWorking
  • 4,011
  • 10
  • 49
  • 90