From 189bdd685f7c879e57208bdf834dfc11ecd9a43b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 28 Mar 2023 09:54:03 -0400 Subject: [PATCH] Properly report network error condition when importing filter list Before this commit, a network error condition was not reported when the filter list was imported, it was only reported afterward when the imported filter list was updated. --- src/js/assets.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/js/assets.js b/src/js/assets.js index 5e2a7dd5d..5a6b97525 100644 --- a/src/js/assets.js +++ b/src/js/assets.js @@ -787,6 +787,7 @@ assets.get = async function(assetKey, options = {}) { contentURLs.push(...assetDetails.cdnURLs); } + let error = 'ENOTFOUND'; for ( const contentURL of contentURLs ) { if ( reIsExternalPath.test(contentURL) && assetDetails.hasLocalURL ) { continue; @@ -794,6 +795,9 @@ assets.get = async function(assetKey, options = {}) { const details = assetDetails.content === 'filters' ? await assets.fetchFilterList(contentURL) : await assets.fetchText(contentURL); + if ( details.error !== undefined ) { + error = details.error; + } if ( details.content === '' ) { continue; } if ( reIsExternalPath.test(contentURL) && options.dontCache !== true ) { assetCacheWrite(assetKey, { @@ -804,7 +808,12 @@ assets.get = async function(assetKey, options = {}) { } return reportBack(details.content, contentURL); } - return reportBack('', '', 'ENOTFOUND'); + if ( assetRegistry[assetKey] !== undefined ) { + registerAssetSource(assetKey, { + error: { time: Date.now(), error } + }); + } + return reportBack('', '', error); }; /******************************************************************************/