1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-02 17:19:38 +02:00

code to migrate obsolete list locations to new locations

This commit is contained in:
gorhill 2015-02-25 16:33:51 -05:00
parent 64d476472d
commit a9ce435f1c

View File

@ -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 = [];