From 0bcb7669e77adc958ee66a97fe9172898cb8131d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 2 Apr 2020 10:39:31 -0400 Subject: [PATCH] Fix exception thrown when a stock asset is removed Related feedback: - https://www.reddit.com/r/uMatrix/comments/ftebgz/ --- src/js/storage.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/storage.js b/src/js/storage.js index 78ababc..a5d6bd4 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -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 =