Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
Fix exception thrown when a stock asset is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 20, 2021
1 parent be3990e commit c2b4adb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
19 changes: 0 additions & 19 deletions assets/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,6 @@
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat"
]
},
"malware-0": {
"content": "filters",
"title": "Malware Domain List",
"contentURL": [
"https://www.malwaredomainlist.com/hostslist/hosts.txt",
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt"
]
},
"malware-1": {
"content": "filters",
"title": "Malware domains",
"contentURL": [
"https://mirror.cedia.org.ec/malwaredomains/justdomains",
"https://mirror1.malwaredomains.com/files/justdomains",
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains",
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains.txt"
],
"supportURL": "http://www.malwaredomains.com/"
},
"dpollock-0": {
"content": "filters",
"updateAfter": 11,
Expand Down
14 changes: 12 additions & 2 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,12 +552,22 @@
var usedCount = this.ubiquitousBlacklist.count;
var duplicateCount = this.ubiquitousBlacklist.duplicateCount;

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);
}

usedCount = this.ubiquitousBlacklist.count - usedCount;
duplicateCount = this.ubiquitousBlacklist.duplicateCount - duplicateCount;

let hostsFileMeta = this.liveHostsFiles.get(details.assetKey);
const hostsFileMeta = this.liveHostsFiles.get(details.assetKey);
if ( hostsFileMeta === undefined ) {
this.liveHostsFiles.delete(details.assetKey);
return;
}

hostsFileMeta.entryCount = usedCount + duplicateCount;
hostsFileMeta.entryUsedCount = usedCount;
};
Expand Down

0 comments on commit c2b4adb

Please sign in to comment.