mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 12:16:21 +03:00
extract library download logic into its own function
Enforcing the DRY principle here.
This commit is contained in:
parent
6ca014dbba
commit
5e004db47c
1 changed files with 4 additions and 13 deletions
|
@ -509,9 +509,7 @@ class Handler {
|
||||||
jarPath = path.join(directory, `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`)
|
jarPath = path.join(directory, `${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix no artifact property when downloading a library
|
const downloadLibrary = async library => {
|
||||||
if (!fs.existsSync(path.join(jarPath, name))) {
|
|
||||||
// Simple lib support, forgot which addon needed this but here you go, Mr special.
|
|
||||||
if (library.url) {
|
if (library.url) {
|
||||||
const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`
|
const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`
|
||||||
await this.downloadAsync(url, jarPath, name, true, eventName)
|
await this.downloadAsync(url, jarPath, name, true, eventName)
|
||||||
|
@ -520,16 +518,9 @@ class Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(library.downloads){
|
if (!fs.existsSync(path.join(jarPath, name))) downloadLibrary(library)
|
||||||
if(!this.checkSum(library.downloads.artifact.sha1, path.join(jarPath, name))){
|
else if (library.downloads && library.downloads.artifact) {
|
||||||
// Simple lib support, forgot which addon needed this but here you go, Mr special.
|
if (!this.checkSum(library.downloads.artifact.sha1, path.join(jarPath, name))) downloadLibrary(library)
|
||||||
if (library.url) {
|
|
||||||
const url = `${library.url}${lib[0].replace(/\./g, '/')}/${lib[1]}/${lib[2]}/${name}`
|
|
||||||
await this.downloadAsync(url, jarPath, name, true, eventName)
|
|
||||||
} else if (library.downloads && library.downloads.artifact) {
|
|
||||||
await this.downloadAsync(library.downloads.artifact.url, jarPath, name, true, eventName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
counter++
|
counter++
|
||||||
|
|
Loading…
Add table
Reference in a new issue