v1.2.1 - Fixed issue w/ native lib parsing.
In 1.12.2, some natives do not provide a rules object and instead just omit the classifier from the natives object. We now check for that. Updated electron to v3.0.12.
This commit is contained in:
@@ -70,31 +70,36 @@ class Library extends Asset {
|
||||
* property has instead specified an OS, the library can be downloaded on any OS EXCLUDING
|
||||
* the one specified.
|
||||
*
|
||||
* @param {Object} rules The Library's download rules.
|
||||
* If the rules are undefined, the natives property will be checked for a matching entry
|
||||
* for the current OS.
|
||||
*
|
||||
* @param {Array.<Object>} rules The Library's download rules.
|
||||
* @param {Object} natives The Library's natives object.
|
||||
* @returns {boolean} True if the Library follows the specified rules, otherwise false.
|
||||
*/
|
||||
static validateRules(rules){
|
||||
if(rules == null) return true
|
||||
static validateRules(rules, natives){
|
||||
if(rules == null) {
|
||||
if(natives == null) {
|
||||
return true
|
||||
} else {
|
||||
return natives[Library.mojangFriendlyOS()] != null
|
||||
}
|
||||
}
|
||||
|
||||
let result = true
|
||||
rules.forEach((rule) => {
|
||||
const action = rule['action']
|
||||
const osProp = rule['os']
|
||||
if(action != null){
|
||||
if(osProp != null){
|
||||
const osName = osProp['name']
|
||||
const osMoj = Library.mojangFriendlyOS()
|
||||
if(action === 'allow'){
|
||||
result = osName === osMoj
|
||||
return
|
||||
} else if(action === 'disallow'){
|
||||
result = osName !== osMoj
|
||||
return
|
||||
}
|
||||
for(let rule of rules){
|
||||
const action = rule.action
|
||||
const osProp = rule.os
|
||||
if(action != null && osProp != null){
|
||||
const osName = osProp.name
|
||||
const osMoj = Library.mojangFriendlyOS()
|
||||
if(action === 'allow'){
|
||||
return osName === osMoj
|
||||
} else if(action === 'disallow'){
|
||||
return osName !== osMoj
|
||||
}
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1160,7 +1165,7 @@ class AssetGuard extends EventEmitter {
|
||||
|
||||
//Check validity of each library. If the hashs don't match, download the library.
|
||||
async.eachLimit(libArr, 5, (lib, cb) => {
|
||||
if(Library.validateRules(lib.rules)){
|
||||
if(Library.validateRules(lib.rules, lib.natives)){
|
||||
let artifact = (lib.natives == null) ? lib.downloads.artifact : lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()].replace('${arch}', process.arch.replace('x', ''))]
|
||||
const libItm = new Library(lib.name, artifact.sha1, artifact.size, artifact.url, path.join(libPath, artifact.path))
|
||||
if(!AssetGuard._validateLocal(libItm.to, 'sha1', libItm.hash)){
|
||||
|
||||
@@ -365,7 +365,7 @@ class ProcessBuilder {
|
||||
fs.ensureDirSync(tempNativePath)
|
||||
for(let i=0; i<libArr.length; i++){
|
||||
const lib = libArr[i]
|
||||
if(Library.validateRules(lib.rules)){
|
||||
if(Library.validateRules(lib.rules, lib.natives)){
|
||||
if(lib.natives == null){
|
||||
const dlInfo = lib.downloads
|
||||
const artifact = dlInfo.artifact
|
||||
|
||||
@@ -126,6 +126,9 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!--<div id="settingsShadersContainer">
|
||||
<div class="settingsModsHeader">Shaderpacks</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
<div id="settingsTabJava" class="settingsTab" style="display: none;">
|
||||
|
||||
Reference in New Issue
Block a user