Skip to content

Commit

Permalink
v1.2.1 - Fixed issue w/ native lib parsing.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dscalzi committed Dec 17, 2018
1 parent f613bdb commit 001a2cb
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 56 deletions.
49 changes: 27 additions & 22 deletions app/assets/js/assetguard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

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
}
static validateRules(rules, natives){
if(rules == null) {
if(natives == null) {
return true
} else {
return natives[Library.mojangFriendlyOS()] != null
}
}

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
}
}

Expand Down Expand Up @@ -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)){
Expand Down
2 changes: 1 addition & 1 deletion app/assets/js/processbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -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;">
Expand Down
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "westeroscraftlauncher",
"version": "1.2.0",
"version": "1.2.1",
"productName": "WesterosCraft Launcher",
"description": "Modded Minecraft Launcher",
"author": "Daniel Scalzi (https://github.com/dscalzi/)",
Expand Down Expand Up @@ -41,7 +41,7 @@
},
"devDependencies": {
"cross-env": "^5.2.0",
"electron": "^3.0.11",
"electron": "^3.0.12",
"electron-builder": "^20.38.3",
"eslint": "^5.10.0"
},
Expand Down

0 comments on commit 001a2cb

Please sign in to comment.