From 46f311678ca6a1b6ef5222f8b267412c9e8304e5 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Sun, 12 Nov 2017 08:30:16 +0500 Subject: [PATCH] Wrap update in try/catch, finally force update --- ...c-pac-script-with-pac-provider-api.tmpl.js | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js index 78d2127..9c07766 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.tmpl.js @@ -533,16 +533,22 @@ }); console.log('Updating from', oldStorage.version, 'to', antiCensorRu.version); - if (window.apis.version.isLeq(oldStorage.version, '0.0.1.5')) { + try { + if (window.apis.version.isLeq(oldStorage.version, '0.0.1.5')) { - // Change semicolons to semicolons followed by newlines in proxy string (raw). - const migrateProxies = (oldStr) => oldStr.replace(/;\\r?\\n?/g, ';\\n'); - const modsMutated = window.apis.pacKitchen.getPacModsRaw(); - modsMutated['customProxyStringRaw'] = migrateProxies(modsMutated['customProxyStringRaw']); - await new Promise( - (resolve) => window.apis.pacKitchen.keepCookedNowAsync(modsMutated, resolve), - ); + // Change semicolons to semicolons followed by newlines in proxy string (raw). + const migrateProxies = (oldStr) => oldStr.replace(/;\\r?\\n?/g, ';\\n'); + const modsMutated = window.apis.pacKitchen.getPacModsRaw(); + if (modsMutated) { + modsMutated['customProxyStringRaw'] = migrateProxies(modsMutated['customProxyStringRaw']); + await new Promise( + (resolve) => window.apis.pacKitchen.keepCookedNowAsync(modsMutated, resolve), + ); + } + } + } catch (e) { + // Swallow update error. } ifUpdatedCb();