From 001a2cbe81a0df5210b282fa8507d2d2a0300532 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Mon, 17 Dec 2018 00:11:23 -0500 Subject: [PATCH] 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. --- app/assets/js/assetguard.js | 47 ++++++++++++++----------- app/assets/js/processbuilder.js | 2 +- app/settings.ejs | 3 ++ package-lock.json | 62 ++++++++++++++++----------------- package.json | 4 +-- 5 files changed, 63 insertions(+), 55 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 1fe6c1f..ceb1edd 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -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.} 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)){ diff --git a/app/assets/js/processbuilder.js b/app/assets/js/processbuilder.js index 20af611..752c5a8 100644 --- a/app/assets/js/processbuilder.js +++ b/app/assets/js/processbuilder.js @@ -365,7 +365,7 @@ class ProcessBuilder { fs.ensureDirSync(tempNativePath) for(let i=0; i +