Change library extraction to be queue based to ensure it completes.

This commit is contained in:
Daniel Scalzi 2018-04-28 20:52:13 -04:00
parent 0216582827
commit d08cfbf248
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
3 changed files with 17 additions and 6 deletions

View File

@ -14,6 +14,10 @@ tracker.on('totaldlprogress', (data) => {
process.send({task: 0, total: data.total, value: data.acc, percent: parseInt((data.acc/data.total)*100), content: 'dl'}) process.send({task: 0, total: data.total, value: data.acc, percent: parseInt((data.acc/data.total)*100), content: 'dl'})
}) })
tracker.on('extracting', () => {
process.send({task: 0.7, content: 'dl'})
})
tracker.on('dlcomplete', () => { tracker.on('dlcomplete', () => {
process.send({task: 1, content: 'dl'}) process.send({task: 1, content: 'dl'})
}) })

View File

@ -191,6 +191,7 @@ class AssetGuard extends EventEmitter {
this.files = new DLTracker([], 0) this.files = new DLTracker([], 0)
this.forge = new DLTracker([], 0) this.forge = new DLTracker([], 0)
this.java = new DLTracker([], 0) this.java = new DLTracker([], 0)
this.extractQueue = []
this.basePath = basePath this.basePath = basePath
this.javaexec = javaexec this.javaexec = javaexec
} }
@ -1284,12 +1285,10 @@ class AssetGuard extends EventEmitter {
} }
self.forge = self._parseDistroModules(serv.modules, serv.mc_version) self.forge = self._parseDistroModules(serv.modules, serv.mc_version)
//Correct our workaround here. // Correct our workaround here.
let decompressqueue = self.forge.callback let decompressqueue = self.forge.callback
self.extractQueue = decompressqueue
self.forge.callback = function(asset, self){ self.forge.callback = function(asset, self){
if(asset.to.toLowerCase().endsWith('.pack.xz')){
AssetGuard._extractPackXZ([asset.to], self.javaexec)
}
if(asset.type === 'forge-hosted' || asset.type === 'forge'){ if(asset.type === 'forge-hosted' || asset.type === 'forge'){
AssetGuard._finalizeForgeAsset(asset, self.basePath) AssetGuard._finalizeForgeAsset(asset, self.basePath)
} }
@ -1315,7 +1314,6 @@ class AssetGuard extends EventEmitter {
_parseDistroModules(modules, version){ _parseDistroModules(modules, version){
let alist = [] let alist = []
let asize = 0; let asize = 0;
//This may be removed soon, considering the most efficient way to extract.
let decompressqueue = [] let decompressqueue = []
for(let i=0; i<modules.length; i++){ for(let i=0; i<modules.length; i++){
let ob = modules[i] let ob = modules[i]
@ -1576,7 +1574,11 @@ class AssetGuard extends EventEmitter {
self.progress -= self[identifier].dlsize self.progress -= self[identifier].dlsize
self[identifier] = new DLTracker([], 0) self[identifier] = new DLTracker([], 0)
if(self.totaldlsize === 0) { if(self.totaldlsize === 0) {
self.emit('extracting')
AssetGuard._extractPackXZ(self.extractQueue, self.javaexec).then(() => {
self.extractQueue = []
self.emit('dlcomplete') self.emit('dlcomplete')
})
} }
}) })
return true return true

View File

@ -440,6 +440,11 @@ function dlAsync(login = true){
setDownloadPercentage(m.value, m.total, m.percent) setDownloadPercentage(m.value, m.total, m.percent)
} else if(m.task === 0.7){
// Download done, extracting.
setLaunchDetails('Extracting libraries..')
} else if(m.task === 1){ } else if(m.task === 1){
// Download will be at 100%, remove the loading from the OS progress bar. // Download will be at 100%, remove the loading from the OS progress bar.