From 86647eb53acd2fce22cb1ec17478fcec254fa951 Mon Sep 17 00:00:00 2001 From: TheFlash787 Date: Wed, 12 Aug 2020 12:32:32 +0100 Subject: [PATCH] Reject if the distribution json is invalid, displaying the error overlay instead of looping. --- app/assets/js/distromanager.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/assets/js/distromanager.js b/app/assets/js/distromanager.js index a4cafff..d103abf 100644 --- a/app/assets/js/distromanager.js +++ b/app/assets/js/distromanager.js @@ -546,11 +546,11 @@ exports.pullRemote = function(){ const distroDest = path.join(ConfigManager.getLauncherDirectory(), 'distribution.json') request(opts, (error, resp, body) => { if(!error){ - try { data = DistroIndex.fromJSON(JSON.parse(body)) - } catch (e) { - reject(e) + resolve(data) + } catch(e) { + reject('We cannot parse the JSON in the remote distribution file') } fs.writeFile(distroDest, body, 'utf-8', (err) => { @@ -574,8 +574,12 @@ exports.pullLocal = function(){ return new Promise((resolve, reject) => { fs.readFile(DEV_MODE ? DEV_PATH : DISTRO_PATH, 'utf-8', (err, d) => { if(!err){ - data = DistroIndex.fromJSON(JSON.parse(d)) - resolve(data) + try { + data = DistroIndex.fromJSON(JSON.parse(d)) + resolve(data) + } catch(e) { + reject('We cannot parse the JSON in the local distribution file') + } } else { reject(err) }