1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Add static release() to StaticNetFilteringEngine class

The method ensures the actual SNFE is properly reset.
This commit is contained in:
Raymond Hill 2021-08-15 11:18:01 -04:00
parent f8f45cab70
commit e9ae8e1a0f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -95,7 +95,10 @@ function pslInit(raw) {
return globals.publicSuffixList;
}
raw = readFileSync(resolve(__dirname, './assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat'), 'utf8')
raw = readFileSync(
resolve(__dirname, './assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat'),
'utf8'
);
if ( typeof raw !== 'string' || raw.trim() === '' ) {
console.error('Unable to populate public suffix list');
return;
@ -147,7 +150,7 @@ async function useLists(lists, options = {}) {
snfe.reset();
if ( Array.isArray(lists) === false || lists.length === 0 ) {
return snfe;
return;
}
let compiler = null;
@ -176,8 +179,6 @@ async function useLists(lists, options = {}) {
// Commit changes
snfe.freeze();
snfe.optimize();
return snfe;
}
/******************************************************************************/
@ -253,9 +254,10 @@ class StaticNetFilteringEngine {
return instance;
}
static release() {
useLists([]);
static async release() {
if ( snfeProxyInstance === null ) { return; }
snfeProxyInstance = null;
await useLists([]);
}
}