Skip to content

Commit

Permalink
fix #2585
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed May 6, 2017
1 parent 73def7e commit fe61cdd
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@
µb.staticNetFilteringEngine.freeze();
µb.redirectEngine.freeze();
µb.cosmeticFilteringEngine.freeze();
µb.selfieManager.create();
µb.selfieManager.destroy();
};

var onLoaded = function(details) {
Expand Down Expand Up @@ -597,7 +597,7 @@

callback();

µb.selfieManager.create();
µb.selfieManager.destroy();
µb.loadingFilterLists = false;
};

Expand Down Expand Up @@ -895,47 +895,31 @@
// some set time.

µBlock.selfieManager = (function() {
var µb = µBlock;
var timer = null;

var create = function() {
timer = null;

var selfie = {
magic: µb.systemSettings.selfieMagic,
magic: this.systemSettings.selfieMagic,
publicSuffixList: publicSuffixList.toSelfie(),
availableFilterLists: µb.availableFilterLists,
staticNetFilteringEngine: µb.staticNetFilteringEngine.toSelfie(),
redirectEngine: µb.redirectEngine.toSelfie(),
cosmeticFilteringEngine: µb.cosmeticFilteringEngine.toSelfie()
availableFilterLists: this.availableFilterLists,
staticNetFilteringEngine: this.staticNetFilteringEngine.toSelfie(),
redirectEngine: this.redirectEngine.toSelfie(),
cosmeticFilteringEngine: this.cosmeticFilteringEngine.toSelfie()
};

vAPI.cacheStorage.set({ selfie: selfie });
};

var createAsync = function(after) {
if ( typeof after !== 'number' ) {
after = µb.selfieAfter;
}

if ( timer !== null ) {
clearTimeout(timer);
}

timer = vAPI.setTimeout(create, after);
};
}.bind(µBlock);

var destroy = function() {
if ( timer !== null ) {
clearTimeout(timer);
timer = null;
}

vAPI.cacheStorage.remove('selfie');
};
timer = vAPI.setTimeout(create, this.selfieAfter);
}.bind(µBlock);

return {
create: createAsync,
destroy: destroy
};
})();
Expand Down Expand Up @@ -1117,6 +1101,10 @@
cached: cached

});
// https://github.com/gorhill/uBlock/issues/2585
// Whenever an asset is overwritten, the current selfie is quite
// likely no longer valid.
this.selfieManager.destroy();
return;
}

Expand Down

0 comments on commit fe61cdd

Please sign in to comment.