mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 01:28:00 +01:00
code to migrate obsolete list locations to new locations
This commit is contained in:
parent
64d476472d
commit
a9ce435f1c
1 changed files with 22 additions and 1 deletions
|
@ -134,6 +134,7 @@
|
|||
|
||||
µBlock.getAvailableLists = function(callback) {
|
||||
var availableLists = {};
|
||||
var relocationMap = {};
|
||||
|
||||
// selected lists
|
||||
var onSelectedListsLoaded = function(store) {
|
||||
|
@ -143,11 +144,17 @@
|
|||
var location, availableEntry, storedEntry;
|
||||
|
||||
while ( location = locations.pop() ) {
|
||||
storedEntry = lists[location];
|
||||
// New location?
|
||||
if ( relocationMap.hasOwnProperty(location) ) {
|
||||
µb.purgeFilterList(location);
|
||||
location = relocationMap[location];
|
||||
}
|
||||
availableEntry = availableLists[location];
|
||||
if ( availableEntry === undefined ) {
|
||||
µb.purgeFilterList(location);
|
||||
continue;
|
||||
}
|
||||
storedEntry = lists[location];
|
||||
availableEntry.off = storedEntry.off || false;
|
||||
µb.assets.setHomeURL(location, availableEntry.homeURL);
|
||||
if ( storedEntry.entryCount !== undefined ) {
|
||||
|
@ -183,6 +190,13 @@
|
|||
if ( /^https?:/.test(location) === false ) {
|
||||
location = 'assets/thirdparties/' + location;
|
||||
}
|
||||
// Migrate obsolete location to new location, if any
|
||||
if ( typeof entry.oldLocation === 'string' ) {
|
||||
if ( /^https?:/.test(entry.oldLocation) === false ) {
|
||||
entry.oldLocation = 'assets/thirdparties/' + entry.oldLocation;
|
||||
}
|
||||
relocationMap[entry.oldLocation] = location;
|
||||
}
|
||||
availableLists[location] = entry;
|
||||
}
|
||||
|
||||
|
@ -370,6 +384,13 @@
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
µBlock.purgeFilterList = function(path) {
|
||||
this.purgeCompiledFilterList(path);
|
||||
this.assets.purge(path);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
µBlock.compileFilters = function(rawText) {
|
||||
var rawEnd = rawText.length;
|
||||
var compiledFilters = [];
|
||||
|
|
Loading…
Reference in a new issue