Browse Source

updater dev mode; reduce sockets msg count

all-modes
pbca26 8 years ago
parent
commit
04f1742c5f
  1. 32
      routes/shepherd.js

32
routes/shepherd.js

@ -379,16 +379,19 @@ shepherd.updateAgama = function() {
localFile: rootLocation + 'patch.zip', localFile: rootLocation + 'patch.zip',
onProgress: function(received, total) { onProgress: function(received, total) {
const percentage = (received * 100) / total; const percentage = (received * 100) / total;
console.log('patch ' + percentage + '% | ' + received + ' bytes out of ' + total + ' bytes.'); if (Math.floor(percentage) % 5 === 0 ||
cache.io.emit('patch', { Math.floor(percentage) % 10 === 0) {
'msg': { console.log('patch ' + percentage + '% | ' + received + ' bytes out of ' + total + ' bytes.');
'status': 'progress', cache.io.emit('patch', {
'type': 'ui', 'msg': {
'progress': percentage, 'status': 'progress',
'bytesTotal': total, 'type': 'ui',
'bytesReceived': received 'progress': percentage,
} 'bytesTotal': total,
}); 'bytesReceived': received
}
});
}
} }
}) })
.then(function() { .then(function() {
@ -402,7 +405,14 @@ shepherd.updateAgama = function() {
console.log('extracting contents'); console.log('extracting contents');
const zip = new AdmZip(rootLocation + 'patch.zip'); const zip = new AdmZip(rootLocation + 'patch.zip');
zip.extractAllTo(/*target path*/rootLocation, /*overwrite*/true);
if (shepherd.appConfig.dev) {
if (!fs.existsSync(`${rootLocation}/patch`)) {
fs.mkdirSync(`${rootLocation}/patch`);
}
}
zip.extractAllTo(/*target path*/rootLocation + (shepherd.appConfig.dev ? '/patch' : ''), /*overwrite*/true);
// TODO: extract files in chunks // TODO: extract files in chunks
cache.io.emit('patch', { cache.io.emit('patch', {
'msg': { 'msg': {

Loading…
Cancel
Save