From 170ff7de5f3c598620dcfa1ea8580ac243c1d976 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Sat, 21 Dec 2024 15:54:57 +0900 Subject: [PATCH] fix: Fallback to previous format if parsing `patches.json` fails in ReVanced API 4 format --- wsEvents/getApp.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/wsEvents/getApp.js b/wsEvents/getApp.js index 02a5cf87..70f4ed7e 100644 --- a/wsEvents/getApp.js +++ b/wsEvents/getApp.js @@ -31,13 +31,25 @@ async function fetchPackages(packages) { */ module.exports = async function getPatches(ws) { const patchesJson = `${global.jarNames.patchesList}`; - if (!existsSync(patchesJson)) { - const java = `${global.javaCmd}`; - const cli = `${global.jarNames.cli}`; - const patches = `${global.jarNames.patchesJar}`; - const command = `${java} -jar ${cli} patches --path=${patchesJson} ${patches}`; + + const java = `${global.javaCmd}`; + const cli = `${global.jarNames.cli}`; + const patches = `${global.jarNames.patchesJar}`; + const command = `${java} -jar "${cli}" patches --path="${patchesJson}" "${patches}"`; + + try { + const patchesList = JSON.parse( + readFileSync(global.jarNames.patchesList, 'utf8') + ); + for (const patches of patchesList) { + if (patches.compatiblePackages === null) continue; + for (const packages of patches.compatiblePackages) { + } + } + } catch (e) { await exec(command); } + const patchesList = JSON.parse( readFileSync(global.jarNames.patchesList, 'utf8') );