diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 1fe6c1f8..ceb1edd0 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 20af6118..752c5a8c 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 +