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.
This commit is contained in:
Raymond Hill 2023-03-28 09:54:03 -04:00
parent d31e14995e
commit 189bdd685f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 10 additions and 1 deletions

View File

@ -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);
};
/******************************************************************************/