From 6a71fc59a4894632dd36f53975b3234df6c04a53 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 29 Sep 2017 08:22:17 -0400 Subject: [PATCH] evict possible remnant of resources.txt from cache [Firefox] --- src/js/assets.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/js/assets.js b/src/js/assets.js index 034eaac5f..da04779dc 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -975,9 +975,24 @@ var updaterStatus, updaterAssetDelayDefault = 120000, updaterAssetDelay = updaterAssetDelayDefault, updaterUpdated = [], - updaterFetched = new Set(); + updaterFetched = new Set(), + noRemoteResources; var updateFirst = function() { + // Firefox extension reviewers do not want uBO/webext to fetch its own + // scriptlets/resources asset from the project's own repo (github.com). + // See: https://github.com/gorhill/uBlock/commit/126110c9a0a0630cd556f5cb215422296a961029 + if ( noRemoteResources === undefined ) { + noRemoteResources = + typeof vAPI.webextFlavor === 'string' && + vAPI.webextFlavor.startsWith('Mozilla-Firefox-'); + } + // This is to ensure the packaged version will always be used (in case + // there is a cache remnant from a pre-stable webext era). + // See https://github.com/uBlockOrigin/uAssets/commit/a6c77af4afb45800d4fd7c268a2a5eab5a64daf3#commitcomment-24642912 + if ( noRemoteResources ) { + api.remove('ublock-resources'); + } updaterStatus = 'updating'; updaterFetched.clear(); updaterUpdated = []; @@ -985,22 +1000,6 @@ var updateFirst = function() { updateNext(); }; -// Firefox extension reviewers do not want uBO/webext to fetch its *own* -// scriptlets/resources asset from the project's *own* repo (github.com). -var noRemoteResources = false; -(function() { - if ( - typeof browser === 'object' && - browser !== null && - browser.runtime instanceof Object && - typeof browser.runtime.getBrowserInfo === 'function' - ) { - browser.runtime.getBrowserInfo().then(function(info) { - noRemoteResources = info.vendor === 'Mozilla'; - }); - } -})(); - var updateNext = function() { var assetDict, cacheDict; @@ -1024,7 +1023,7 @@ var updateNext = function() { continue; } // Update of user scripts/resources forbidden? - if ( assetKey === 'ublock-resources' && noRemoteResources === true ) { + if ( assetKey === 'ublock-resources' && noRemoteResources ) { continue; } if (