mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-21 06:09:51 +01:00
Merge pull request #380 from AltarikMC/dev
2.1.6 - Fix mod extract not finish when game start
This commit is contained in:
commit
c42d4c397d
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "altarik-launcher",
|
"name": "altarik-launcher",
|
||||||
"author": "Altarik",
|
"author": "Altarik",
|
||||||
"version": "2.1.5",
|
"version": "2.1.6",
|
||||||
"description": "Altarik Launcher",
|
"description": "Altarik Launcher",
|
||||||
"main": "src/server/main.js",
|
"main": "src/server/main.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
@ -189,10 +189,14 @@ export default class Minecraft {
|
|||||||
// const shaderFolder = join(this.minecraftpath, 'shaderpacks')
|
// const shaderFolder = join(this.minecraftpath, 'shaderpacks')
|
||||||
if (fs.existsSync(modsFolder)) { fs.rmSync(modsFolder, { recursive: true }) }
|
if (fs.existsSync(modsFolder)) { fs.rmSync(modsFolder, { recursive: true }) }
|
||||||
// if (fs.existsSync(shaderFolder)) { fs.rmSync(shaderFolder, { recursive: true }) }
|
// if (fs.existsSync(shaderFolder)) { fs.rmSync(shaderFolder, { recursive: true }) }
|
||||||
|
let chapterFound = false
|
||||||
for (const i in this.modsList) {
|
for (const i in this.modsList) {
|
||||||
if (Number(i) === chapterId) {
|
if (Number(i) === chapterId) {
|
||||||
|
chapterFound = true
|
||||||
const chapter = this.modsList[i]
|
const chapter = this.modsList[i]
|
||||||
|
const modsList = []
|
||||||
for (const j in chapter.modspack.mods) {
|
for (const j in chapter.modspack.mods) {
|
||||||
|
modsList.push(new Promise((resolve, reject) => {
|
||||||
event.sender.send('progress', { type: 'mods', task: 0, total: chapter.modspack.mods.length })
|
event.sender.send('progress', { type: 'mods', task: 0, total: chapter.modspack.mods.length })
|
||||||
const modpackFolder = join(this.minecraftpath, 'modpack', chapter.title)
|
const modpackFolder = join(this.minecraftpath, 'modpack', chapter.title)
|
||||||
if (!fs.existsSync(modpackFolder)) { fs.mkdirSync(modpackFolder, { recursive: true }) }
|
if (!fs.existsSync(modpackFolder)) { fs.mkdirSync(modpackFolder, { recursive: true }) }
|
||||||
@ -201,30 +205,34 @@ export default class Minecraft {
|
|||||||
fs.accessSync(path, fs.W_OK)
|
fs.accessSync(path, fs.W_OK)
|
||||||
hashFile(path, { algorithm: 'sha1' }).then(sha1 => {
|
hashFile(path, { algorithm: 'sha1' }).then(sha1 => {
|
||||||
if (sha1 === chapter.modspack.sha1sum[j]) {
|
if (sha1 === chapter.modspack.sha1sum[j]) {
|
||||||
this.unzipMods(path).catch(err => {
|
this.unzipMods(path)
|
||||||
reject(err)
|
.then(() => resolve())
|
||||||
})
|
.catch(err => reject(err))
|
||||||
} else {
|
} else {
|
||||||
logger.warn(`sha1sum ${sha1} don't correspond to ${chapter.modspack.sha1sum[j]} of mods ${path}`)
|
logger.warn(`sha1sum ${sha1} don't correspond to ${chapter.modspack.sha1sum[j]} of mods ${path}`)
|
||||||
this.downloadAndExtractMods(chapter.modspack.mods[j], path).catch(err => {
|
this.downloadAndExtractMods(chapter.modspack.mods[j], path).then(() => resolve()).catch(err => reject(err))
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
reject(new Error('Can obtain md5 hash of file ' + path + ': ' + err))
|
reject(new Error('Can obtain md5 hash of file ' + path + ': ' + err))
|
||||||
})
|
})
|
||||||
event.sender.send('progress', { type: 'mods', task: Number(j) + 1, total: chapter.modspack.mods.length })
|
event.sender.send('progress', { type: 'mods', task: Number(j) + 1, total: chapter.modspack.mods.length })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.downloadAndExtractMods(chapter.modspack.mods[j], path).catch(err => {
|
this.downloadAndExtractMods(chapter.modspack.mods[j], path).then(() => resolve()).catch(err => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
Promise.all(modsList).then(() => {
|
||||||
|
resolve(chapter)
|
||||||
|
}).catch(err => {
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolve(chapter)
|
if (chapterFound === false) {
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reject(new Error("didn't found the correct chapter" + chapterId))
|
reject(new Error("didn't found the correct chapter" + chapterId))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user