Clear internal cache when loading redirect rules

Related commit:
- 3e5c9e00ab

This fix a regression: newly added redirect rules
could end up not being taken into account unless
uBO was restarted.
This commit is contained in:
Raymond Hill 2019-08-24 13:48:50 -04:00
parent 4a60810389
commit e0b8cf24d1
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 10 additions and 7 deletions

View File

@ -266,13 +266,6 @@ const RedirectEngine = function() {
this.resources = new Map(); this.resources = new Map();
this.reset(); this.reset();
this.resourceNameRegister = ''; this.resourceNameRegister = '';
// Internal use
this._missedQueryHash = '';
this._src = '';
this._srcAll = [ '*' ];
this._des = '';
this._desAll = [ '*' ];
}; };
/******************************************************************************/ /******************************************************************************/
@ -281,9 +274,18 @@ RedirectEngine.prototype.reset = function() {
this.rules = new Map(); this.rules = new Map();
this.ruleSources = new Set(); this.ruleSources = new Set();
this.ruleDestinations = new Set(); this.ruleDestinations = new Set();
this.resetCache();
this.modifyTime = Date.now(); this.modifyTime = Date.now();
}; };
RedirectEngine.prototype.resetCache = function() {
this._missedQueryHash = '';
this._src = '';
this._srcAll = [ '*' ];
this._des = '';
this._desAll = [ '*' ];
};
/******************************************************************************/ /******************************************************************************/
RedirectEngine.prototype.freeze = function() { RedirectEngine.prototype.freeze = function() {
@ -594,6 +596,7 @@ RedirectEngine.prototype.fromSelfie = function(path) {
this.rules = new Map(selfie.rules); this.rules = new Map(selfie.rules);
this.ruleSources = new Set(selfie.ruleSources); this.ruleSources = new Set(selfie.ruleSources);
this.ruleDestinations = new Set(selfie.ruleDestinations); this.ruleDestinations = new Set(selfie.ruleDestinations);
this.resetCache();
this.modifyTime = Date.now(); this.modifyTime = Date.now();
return true; return true;
}); });