Skip to content

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 Apr 2, 2020
1 parent 89b7e02 commit 0bcb766
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 0bcb766

Please sign in to comment.