Commit a6e78a4d authored by Amy Yan's avatar Amy Yan

added console print download progress

parent 614085f5
...@@ -160,7 +160,18 @@ ipcMain.on("getDeeplink", (event) => { ...@@ -160,7 +160,18 @@ ipcMain.on("getDeeplink", (event) => {
function download(url, fileName, cb) { function download(url, fileName, cb) {
let dest = path.join(app.getPath('temp'), fileName + ".zip"); let dest = path.join(app.getPath('temp'), fileName + ".zip");
let file = fs.createWriteStream(dest); let file = fs.createWriteStream(dest);
let request = https.get(url, function(response) { let request = https.get(url, function(response) {
var partiallength = 0
var totallength = parseInt(response.headers['content-length'], 10);
response.on("data", function(chunk) {
partiallength += chunk.length
console.log(partiallength / totallength)
ipcMain.emit('downloadProgress', partiallength / totallength)
});
response.pipe(file); response.pipe(file);
file.on('finish', function() { file.on('finish', function() {
file.close(cb(null, dest)); // async call of the callback file.close(cb(null, dest)); // async call of the callback
......
...@@ -30,11 +30,18 @@ ...@@ -30,11 +30,18 @@
props: [ props: [
'downloadQueue' 'downloadQueue'
], ],
mounted: function(){
this.$on('downloadProgress', (decimal) => {
this.$data.downloadProgress = decimal;
console.log(this.$data.downloadProgress)
});
},
data: function() { data: function() {
return { return {
showUpdateOverlay: false, showUpdateOverlay: false,
showDownloadManager: false, showDownloadManager: false,
isUpdateAvailable: false isUpdateAvailable: false,
downloadProgress: 0
} }
}, },
methods: { methods: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment