1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-04-27 09:02:08 +12:00

Fix exception thrown when a stock asset is removed

Related feedback:
- https://www.reddit.com/r/uMatrix/comments/ftebgz/
This commit is contained in:
Raymond Hill 2020-04-02 10:39:31 -04:00
parent 89b7e026c3
commit 0bcb7669e7
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -496,9 +496,19 @@ self.addEventListener('rawSettingsChanged', ( ) => {
const addedCount = this.ubiquitousBlacklistRef.addedCount;
const addCount = this.ubiquitousBlacklistRef.addCount;
this.mergeHostsFileContent(details.content);
// https://www.reddit.com/r/uMatrix/comments/ftebgz/
// Be ready to deal with a removed asset.
if ( typeof details.content === 'string' && details.content !== '' ) {
this.mergeHostsFileContent(details.content);
}
const hostsFileMeta = this.liveHostsFiles.get(details.assetKey);
if ( hostsFileMeta === undefined ) {
this.liveHostsFiles.delete(details.assetKey);
return;
}
hostsFileMeta.entryCount =
this.ubiquitousBlacklistRef.addCount - addCount;
hostsFileMeta.entryUsedCount =