|
@@ -410,15 +410,12 @@ function _finalizeForgeAsset(asset, basePath){
|
|
|
*/
|
|
*/
|
|
|
function startAsyncProcess(identifier, limit = 5){
|
|
function startAsyncProcess(identifier, limit = 5){
|
|
|
let win = remote.getCurrentWindow()
|
|
let win = remote.getCurrentWindow()
|
|
|
-
|
|
|
|
|
let acc = 0
|
|
let acc = 0
|
|
|
const concurrentDlTracker = instance[identifier]
|
|
const concurrentDlTracker = instance[identifier]
|
|
|
const concurrentDlQueue = concurrentDlTracker.dlqueue.slice(0)
|
|
const concurrentDlQueue = concurrentDlTracker.dlqueue.slice(0)
|
|
|
- console.log(concurrentDlQueue);
|
|
|
|
|
if(concurrentDlQueue.length === 0){
|
|
if(concurrentDlQueue.length === 0){
|
|
|
return false
|
|
return false
|
|
|
} else {
|
|
} else {
|
|
|
- console.log(concurrentDlQueue)
|
|
|
|
|
async.eachLimit(concurrentDlQueue, limit, function(asset, cb){
|
|
async.eachLimit(concurrentDlQueue, limit, function(asset, cb){
|
|
|
let count = 0;
|
|
let count = 0;
|
|
|
mkpath.sync(path.join(asset.to, ".."))
|
|
mkpath.sync(path.join(asset.to, ".."))
|
|
@@ -441,6 +438,7 @@ function startAsyncProcess(identifier, limit = 5){
|
|
|
console.log('Failed to download ' + asset.from + '. Response code', resp.statusCode)
|
|
console.log('Failed to download ' + asset.from + '. Response code', resp.statusCode)
|
|
|
instance.progress += asset.size*1
|
|
instance.progress += asset.size*1
|
|
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
|
|
|
|
+ instance.emit('totaldlprogress', {acc: instance.progress, total: instance.totaldlsize})
|
|
|
cb()
|
|
cb()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -451,6 +449,7 @@ function startAsyncProcess(identifier, limit = 5){
|
|
|
instance.emit(identifier + 'dlprogress', acc)
|
|
instance.emit(identifier + 'dlprogress', acc)
|
|
|
//console.log(identifier + ' Progress', acc/instance[identifier].dlsize)
|
|
//console.log(identifier + ' Progress', acc/instance[identifier].dlsize)
|
|
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
|
win.setProgressBar(instance.progress/instance.totaldlsize)
|
|
|
|
|
+ instance.emit('totaldlprogress', {acc: instance.progress, total: instance.totaldlsize})
|
|
|
})
|
|
})
|
|
|
}, function(err){
|
|
}, function(err){
|
|
|
if(err){
|
|
if(err){
|
|
@@ -592,7 +591,6 @@ function _assetChainValidateAssets(versionData, basePath, indexData){
|
|
|
cb()
|
|
cb()
|
|
|
}, function(err){
|
|
}, function(err){
|
|
|
instance.assets = new DLTracker(assetDlQueue, dlSize)
|
|
instance.assets = new DLTracker(assetDlQueue, dlSize)
|
|
|
- instance.totaldlsize += dlSize*1
|
|
|
|
|
fulfill()
|
|
fulfill()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -630,7 +628,6 @@ function validateLibraries(versionData, basePath){
|
|
|
cb()
|
|
cb()
|
|
|
}, function(err){
|
|
}, function(err){
|
|
|
instance.libraries = new DLTracker(libDlQueue, dlSize)
|
|
instance.libraries = new DLTracker(libDlQueue, dlSize)
|
|
|
- instance.totaldlsize += dlSize*1
|
|
|
|
|
fulfill()
|
|
fulfill()
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -697,7 +694,7 @@ function validateLogConfig(versionData, basePath){
|
|
|
|
|
|
|
|
if(!_validateLocal(logConfig.to, 'sha1', logConfig.hash)){
|
|
if(!_validateLocal(logConfig.to, 'sha1', logConfig.hash)){
|
|
|
instance.files.dlqueue.push(logConfig)
|
|
instance.files.dlqueue.push(logConfig)
|
|
|
- instance.files.dlsize += client.size*1
|
|
|
|
|
|
|
+ instance.files.dlsize += logConfig.size*1
|
|
|
fulfill()
|
|
fulfill()
|
|
|
} else {
|
|
} else {
|
|
|
fulfill()
|
|
fulfill()
|
|
@@ -735,7 +732,6 @@ function validateDistribution(serverpackid, basePath){
|
|
|
_finalizeForgeAsset(asset, basePath)
|
|
_finalizeForgeAsset(asset, basePath)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- instance.totaldlsize += instance.forge.dlsize*1
|
|
|
|
|
fulfill(serv)
|
|
fulfill(serv)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -863,6 +859,13 @@ function processDlQueues(identifiers = [{id:'assets', limit:20}, {id:'libraries'
|
|
|
|
|
|
|
|
let shouldFire = true
|
|
let shouldFire = true
|
|
|
|
|
|
|
|
|
|
+ // Assign global dltracking variables.
|
|
|
|
|
+ instance.totaldlsize = 0
|
|
|
|
|
+ instance.progress = 0
|
|
|
|
|
+ for(let i=0; i<identifiers.length; i++){
|
|
|
|
|
+ instance.totaldlsize += instance[identifiers[i].id].dlsize
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
for(let i=0; i<identifiers.length; i++){
|
|
for(let i=0; i<identifiers.length; i++){
|
|
|
let iden = identifiers[i]
|
|
let iden = identifiers[i]
|
|
|
let r = startAsyncProcess(iden.id, iden.limit)
|
|
let r = startAsyncProcess(iden.id, iden.limit)
|