@@ -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 && / ^ h t t p s ? : \/ \/ / . 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
538383var saveAssetCacheRegistry = ( function ( ) {
0 commit comments