Skip to content

Commit 36956cb

Browse files
committed
remove obsolete resource caching code
1 parent 2ef892c commit 36956cb

4 files changed

Lines changed: 15 additions & 262 deletions

File tree

src/js/3p-filters.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -547,16 +547,9 @@ var fromCloudData = function(data, append) {
547547
checked = data.ignoreGenericCosmeticFilters === true || append && elem.checked;
548548
elem.checked = listDetails.ignoreGenericCosmeticFilters = checked;
549549

550-
var listKey;
551-
for ( i = 0, n = data.selectedLists.length; i < n; i++ ) {
552-
listKey = data.selectedLists[i];
553-
if ( listDetails.aliases[listKey] ) {
554-
data.selectedLists[i] = listDetails.aliases[listKey];
555-
}
556-
}
557550
var selectedSet = new Set(data.selectedLists),
558551
listEntries = uDom('#lists .listEntry'),
559-
listEntry, input;
552+
listEntry, listKey, input;
560553
for ( i = 0, n = listEntries.length; i < n; i++ ) {
561554
listEntry = listEntries.at(i);
562555
listKey = listEntry.attr('data-listkey');

src/js/assets.js

Lines changed: 6 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -167,157 +167,6 @@ api.fetchText = function(url, onLoad, onError) {
167167
}
168168
};
169169

170-
/*******************************************************************************
171-
172-
TODO(seamless migration):
173-
This block of code will be removed when I am confident all users have
174-
moved to a version of uBO which does not require the old way of caching
175-
assets.
176-
177-
api.listKeyAliases: a map of old asset keys to new asset keys.
178-
179-
migrate(): to seamlessly migrate the old cache manager to the new one:
180-
- attempt to preserve and move content of cached assets to new locations;
181-
- removes all traces of now obsolete cache manager entries in cacheStorage.
182-
183-
This code will typically execute only once, when the newer version of uBO
184-
is first installed and executed.
185-
186-
**/
187-
188-
api.listKeyAliases = {
189-
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat": "public_suffix_list.dat",
190-
"assets/user/filters.txt": "user-filters",
191-
"assets/ublock/resources.txt": "ublock-resources",
192-
"assets/ublock/filters.txt": "ublock-filters",
193-
"assets/ublock/privacy.txt": "ublock-privacy",
194-
"assets/ublock/unbreak.txt": "ublock-unbreak",
195-
"assets/ublock/badware.txt": "ublock-badware",
196-
"assets/ublock/experimental.txt": "ublock-experimental",
197-
"https://easylist-downloads.adblockplus.org/easylistchina.txt": "CHN-0",
198-
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjxlist.txt": "CHN-1",
199-
"https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt": "CHN-2",
200-
"https://easylist-downloads.adblockplus.org/easylistgermany.txt": "DEU-0",
201-
"https://adblock.dk/block.csv": "DNK-0",
202-
"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt": "easylist",
203-
"https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt": "easylist-nocosmetic",
204-
"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt": "easyprivacy",
205-
"https://easylist-downloads.adblockplus.org/fanboy-annoyance.txt": "fanboy-annoyance",
206-
"https://easylist-downloads.adblockplus.org/fanboy-social.txt": "fanboy-social",
207-
"https://easylist-downloads.adblockplus.org/liste_fr.txt": "FRA-0",
208-
"http://adblock.gardar.net/is.abp.txt": "ISL-0",
209-
"https://easylist-downloads.adblockplus.org/easylistitaly.txt": "ITA-0",
210-
"https://dl.dropboxusercontent.com/u/1289327/abpxfiles/filtri.txt": "ITA-1",
211-
"https://easylist-downloads.adblockplus.org/advblock.txt": "RUS-0",
212-
"https://easylist-downloads.adblockplus.org/bitblock.txt": "RUS-1",
213-
"https://filters.adtidy.org/extension/chromium/filters/1.txt": "RUS-2",
214-
"https://adguard.com/en/filter-rules.html?id=1": "RUS-2",
215-
"https://easylist-downloads.adblockplus.org/easylistdutch.txt": "NLD-0",
216-
"https://notabug.org/latvian-list/adblock-latvian/raw/master/lists/latvian-list.txt": "LVA-0",
217-
"http://hosts-file.net/.%5Cad_servers.txt": "hphosts",
218-
"http://adblock.ee/list.php": "EST-0",
219-
"https://s3.amazonaws.com/lists.disconnect.me/simple_malvertising.txt": "disconnect-malvertising",
220-
"https://s3.amazonaws.com/lists.disconnect.me/simple_malware.txt": "disconnect-malware",
221-
"https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt": "disconnect-tracking",
222-
"https://www.certyficate.it/adblock/adblock.txt": "POL-0",
223-
"https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/polish-adblock-filters/adblock.txt": "POL-0",
224-
"https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": "awrl-0",
225-
"http://adb.juvander.net/Finland_adb.txt": "FIN-0",
226-
"https://raw.githubusercontent.com/gfmaster/adblock-korea-contrib/master/filter.txt": "KOR-0",
227-
"https://raw.githubusercontent.com/yous/YousList/master/youslist.txt": "KOR-1",
228-
"https://www.fanboy.co.nz/fanboy-korean.txt": "KOR-2",
229-
"https://raw.githubusercontent.com/heradhis/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
230-
"https://raw.githubusercontent.com/ABPindo/indonesianadblockrules/master/subscriptions/abpindo.txt": "IDN-0",
231-
"https://raw.githubusercontent.com/k2jp/abp-japanese-filters/master/abpjf.txt": "JPN-0",
232-
"https://raw.githubusercontent.com/liamja/Prebake/master/obtrusive.txt": "EU-prebake",
233-
"https://easylist-downloads.adblockplus.org/Liste_AR.txt": "ara-0",
234-
"http://margevicius.lt/easylistlithuania.txt": "LTU-0",
235-
"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt": "malware-0",
236-
"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains": "malware-1",
237-
"http://malwaredomains.lehigh.edu/files/immortal_domains.txt": "malware-2",
238-
"assets/thirdparties/pgl.yoyo.org/as/serverlist": "plowe-0",
239-
"https://raw.githubusercontent.com/easylist/EasyListHebrew/master/EasyListHebrew.txt": "ISR-0",
240-
"https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt": "reek-0",
241-
"https://raw.githubusercontent.com/szpeter80/hufilter/master/hufilter.txt": "HUN-0",
242-
"https://raw.githubusercontent.com/tomasko126/easylistczechandslovak/master/filters.txt": "CZE-0",
243-
"http://someonewhocares.org/hosts/hosts": "dpollock-0",
244-
"https://raw.githubusercontent.com/Dawsey21/Lists/master/adblock-list.txt": "spam404-0",
245-
"http://stanev.org/abp/adblock_bg.txt": "BGR-0",
246-
"http://winhelp2002.mvps.org/hosts.txt": "mvps-0",
247-
"https://www.fanboy.co.nz/enhancedstats.txt": "fanboy-enhanced",
248-
"https://www.fanboy.co.nz/fanboy-antifacebook.txt": "fanboy-thirdparty_social",
249-
"https://easylist-downloads.adblockplus.org/easylistspanish.txt": "spa-0",
250-
"https://www.fanboy.co.nz/fanboy-swedish.txt": "SWE-0",
251-
"https://www.fanboy.co.nz/r/fanboy-ultimate.txt": "fanboy-ultimate",
252-
"https://filters.adtidy.org/extension/chromium/filters/13.txt": "TUR-0",
253-
"https://adguard.com/filter-rules.html?id=13": "TUR-0",
254-
"https://www.fanboy.co.nz/fanboy-vietnam.txt": "VIE-0",
255-
"https://www.void.gr/kargig/void-gr-filters.txt": "GRC-0",
256-
"https://raw.githubusercontent.com/betterwebleon/slovenian-list/master/filters.txt": "SVN-0"
257-
};
258-
259-
var migrate = function(callback) {
260-
var entries,
261-
moveCount = 0,
262-
toRemove = [];
263-
264-
var countdown = function(change) {
265-
moveCount -= (change || 0);
266-
if ( moveCount !== 0 ) { return; }
267-
vAPI.cacheStorage.remove(toRemove);
268-
saveAssetCacheRegistry();
269-
callback();
270-
};
271-
272-
var onContentRead = function(oldKey, newKey, bin) {
273-
var content = bin && bin['cached_asset_content://' + oldKey] || undefined;
274-
if ( content ) {
275-
assetCacheRegistry[newKey] = {
276-
readTime: Date.now(),
277-
writeTime: entries[oldKey]
278-
};
279-
if ( reIsExternalPath.test(oldKey) ) {
280-
assetCacheRegistry[newKey].remoteURL = oldKey;
281-
}
282-
bin = {};
283-
bin['cache/' + newKey] = content;
284-
vAPI.cacheStorage.set(bin);
285-
}
286-
countdown(1);
287-
};
288-
289-
var onEntries = function(bin) {
290-
entries = bin && bin['cached_asset_entries'];
291-
if ( !entries ) { return callback(); }
292-
if ( bin && bin['assetCacheRegistry'] ) {
293-
assetCacheRegistry = bin['assetCacheRegistry'];
294-
}
295-
var aliases = api.listKeyAliases;
296-
for ( var oldKey in entries ) {
297-
if ( oldKey.endsWith('assets/user/filters.txt') ) { continue; }
298-
var newKey = aliases[oldKey];
299-
if ( !newKey && /^https?:\/\//.test(oldKey) ) {
300-
newKey = oldKey;
301-
}
302-
if ( newKey ) {
303-
vAPI.cacheStorage.get(
304-
'cached_asset_content://' + oldKey,
305-
onContentRead.bind(null, oldKey, newKey)
306-
);
307-
moveCount += 1;
308-
}
309-
toRemove.push('cached_asset_content://' + oldKey);
310-
}
311-
toRemove.push('cached_asset_entries', 'extensionLastVersion');
312-
countdown();
313-
};
314-
315-
vAPI.cacheStorage.get(
316-
[ 'cached_asset_entries', 'assetCacheRegistry' ],
317-
onEntries
318-
);
319-
};
320-
321170
/*******************************************************************************
322171
323172
The purpose of the asset source registry is to keep key detail information
@@ -523,16 +372,12 @@ var getAssetCacheRegistry = function(callback) {
523372
}
524373
};
525374

526-
var migrationDone = function() {
527-
vAPI.cacheStorage.get('assetCacheRegistry', function(bin) {
528-
if ( bin && bin.assetCacheRegistry ) {
529-
assetCacheRegistry = bin.assetCacheRegistry;
530-
}
531-
registryReady();
532-
});
533-
};
534-
535-
migrate(migrationDone);
375+
vAPI.cacheStorage.get('assetCacheRegistry', function(bin) {
376+
if ( bin && bin.assetCacheRegistry ) {
377+
assetCacheRegistry = bin.assetCacheRegistry;
378+
}
379+
registryReady();
380+
});
536381
};
537382

538383
var saveAssetCacheRegistry = (function() {

src/js/messaging.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -711,15 +711,7 @@ var backupUserData = function(callback) {
711711
dynamicFilteringString: µb.permanentFirewall.toString(),
712712
urlFilteringString: µb.permanentURLFiltering.toString(),
713713
hostnameSwitchesString: µb.hnSwitches.toString(),
714-
userFilters: '',
715-
// TODO(seamless migration):
716-
// The following is strictly for convenience, to be minimally
717-
// forward-compatible. This will definitely be removed in the
718-
// short term, as I do not expect the need to install an older
719-
// version of uBO to ever be needed beyond the short term.
720-
// >>>>>>>>
721-
filterLists: µb.oldDataFromNewListKeys(µb.selectedFilterLists)
722-
// <<<<<<<<
714+
userFilters: ''
723715
};
724716

725717
var onUserFiltersReady = function(details) {
@@ -760,17 +752,8 @@ var restoreUserData = function(request) {
760752
lastBackupTime: 0
761753
});
762754
µb.assets.put(µb.userFiltersPath, userData.userFilters);
763-
764-
// 'filterLists' is available up to uBO v1.10.4, not beyond.
765-
// 'selectedFilterLists' is available from uBO v1.11 and beyond.
766-
var listKeys;
767755
if ( Array.isArray(userData.selectedFilterLists) ) {
768-
listKeys = userData.selectedFilterLists;
769-
} else if ( userData.filterLists instanceof Object ) {
770-
listKeys = µb.newListKeysFromOldData(userData.filterLists);
771-
}
772-
if ( listKeys !== undefined ) {
773-
µb.saveSelectedFilterLists(listKeys, restart);
756+
µb.saveSelectedFilterLists(userData.selectedFilterLists, restart);
774757
} else {
775758
restart();
776759
}
@@ -828,8 +811,7 @@ var getLists = function(callback) {
828811
ignoreGenericCosmeticFilters: µb.userSettings.ignoreGenericCosmeticFilters,
829812
netFilterCount: µb.staticNetFilteringEngine.getFilterCount(),
830813
parseCosmeticFilters: µb.userSettings.parseAllABPHideFilters,
831-
userFiltersPath: µb.userFiltersPath,
832-
aliases: µb.assets.listKeyAliases
814+
userFiltersPath: µb.userFiltersPath
833815
};
834816
var onMetadataReady = function(entries) {
835817
r.cache = entries;

src/js/storage.js

Lines changed: 5 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,16 @@
168168

169169
µBlock.loadSelectedFilterLists = function(callback) {
170170
var µb = this;
171-
vAPI.storage.get([ 'selectedFilterLists', 'remoteBlacklists' ], function(bin) {
172-
if ( !bin || !bin.selectedFilterLists && !bin.remoteBlacklists ) {
173-
// Select default filter lists if first-time launch.
171+
vAPI.storage.get('selectedFilterLists', function(bin) {
172+
// Select default filter lists if first-time launch.
173+
if ( !bin || Array.isArray(bin.selectedFilterLists) === false ) {
174174
µb.assets.metadata(function(availableLists) {
175175
µb.saveSelectedFilterLists(µb.autoSelectRegionalFilterLists(availableLists));
176176
callback();
177177
});
178178
return;
179179
}
180-
var listKeys = [];
181-
if ( bin.selectedFilterLists ) {
182-
listKeys = bin.selectedFilterLists;
183-
} else if ( bin.remoteBlacklists ) {
184-
var oldListKeys = µb.newListKeysFromOldData(bin.remoteBlacklists);
185-
if ( oldListKeys.sort().join() !== listKeys.sort().join() ) {
186-
listKeys = oldListKeys;
187-
µb.saveSelectedFilterLists(listKeys);
188-
}
189-
// TODO(seamless migration):
190-
// Uncomment when all have moved to v1.11 and beyond.
191-
//vAPI.storage.remove('remoteBlacklists');
192-
}
193-
µb.selectedFilterLists = listKeys;
180+
µb.selectedFilterLists = bin.selectedFilterLists;
194181
callback();
195182
});
196183
};
@@ -213,63 +200,12 @@
213200
}
214201
newKeys = this.arrayFrom(newSet);
215202
var bin = {
216-
selectedFilterLists: newKeys,
217-
remoteBlacklists: this.oldDataFromNewListKeys(newKeys)
203+
selectedFilterLists: newKeys
218204
};
219205
this.selectedFilterLists = newKeys;
220206
vAPI.storage.set(bin, callback);
221207
};
222208

223-
// TODO(seamless migration):
224-
// Remove when all have moved to v1.11 and beyond.
225-
// >>>>>>>>
226-
µBlock.newListKeysFromOldData = function(oldLists) {
227-
var aliases = this.assets.listKeyAliases,
228-
listKeys = [], newKey;
229-
for ( var oldKey in oldLists ) {
230-
if ( oldLists[oldKey].off !== true ) {
231-
newKey = aliases[oldKey];
232-
listKeys.push(newKey ? newKey : oldKey);
233-
}
234-
}
235-
return listKeys;
236-
};
237-
238-
µBlock.oldDataFromNewListKeys = function(selectedFilterLists) {
239-
var µb = this,
240-
remoteBlacklists = {};
241-
var reverseAliases = Object.keys(this.assets.listKeyAliases).reduce(
242-
function(a, b) {
243-
a[µb.assets.listKeyAliases[b]] = b; return a;
244-
},
245-
{}
246-
);
247-
remoteBlacklists = selectedFilterLists.reduce(
248-
function(a, b) {
249-
a[reverseAliases[b] || b] = { off: false };
250-
return a;
251-
},
252-
{}
253-
);
254-
remoteBlacklists = Object.keys(µb.assets.listKeyAliases).reduce(
255-
function(a, b) {
256-
var aliases = µb.assets.listKeyAliases;
257-
if (
258-
b.startsWith('assets/') &&
259-
aliases[b] !== 'public_suffix_list.dat' &&
260-
aliases[b] !== 'ublock-resources' &&
261-
!a[b]
262-
) {
263-
a[b] = { off: true };
264-
}
265-
return a;
266-
},
267-
remoteBlacklists
268-
);
269-
return remoteBlacklists;
270-
};
271-
// <<<<<<<<
272-
273209
/******************************************************************************/
274210

275211
µBlock.applyFilterListSelection = function(details, callback) {
@@ -1028,9 +964,6 @@
1028964
if ( Array.isArray(data.selectedFilterLists) ) {
1029965
bin.selectedFilterLists = data.selectedFilterLists;
1030966
binNotEmpty = true;
1031-
} else if ( typeof data.filterLists === 'object' ) {
1032-
bin.selectedFilterLists = µb.newListKeysFromOldData(data.filterLists);
1033-
binNotEmpty = true;
1034967
}
1035968

1036969
if ( typeof data.netWhitelist === 'string' ) {

0 commit comments

Comments
 (0)