Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/synchronizer.js

Issue 29800557: Issue 6559 - Use Map object for known subscriptions (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Move check for known subscription into removeSubscription Created June 6, 2018, 11 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/subscriptionClasses.js ('K') | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 let subscription = Subscription.fromURL(downloadable.redirectURL || 193 let subscription = Subscription.fromURL(downloadable.redirectURL ||
194 downloadable.url); 194 downloadable.url);
195 if (downloadable.redirectURL && 195 if (downloadable.redirectURL &&
196 downloadable.redirectURL != downloadable.url) 196 downloadable.redirectURL != downloadable.url)
197 { 197 {
198 let oldSubscription = Subscription.fromURL(downloadable.url); 198 let oldSubscription = Subscription.fromURL(downloadable.url);
199 subscription.title = oldSubscription.title; 199 subscription.title = oldSubscription.title;
200 subscription.disabled = oldSubscription.disabled; 200 subscription.disabled = oldSubscription.disabled;
201 subscription.lastCheck = oldSubscription.lastCheck; 201 subscription.lastCheck = oldSubscription.lastCheck;
202 202
203 let listed = (oldSubscription.url in FilterStorage.knownSubscriptions); 203 let listed = FilterStorage.knownSubscriptions.has(oldSubscription.url);
204 if (listed) 204 FilterStorage.removeSubscription(oldSubscription);
kzar 2018/06/07 13:52:26 But we already have `listed` here, but now we don'
Manish Jethani 2018/06/07 14:29:46 Yeah I have to admit the last change is not exactl
205 FilterStorage.removeSubscription(oldSubscription);
206 205
207 delete Subscription.knownSubscriptions[oldSubscription.url]; 206 Subscription.knownSubscriptions.delete(oldSubscription.url);
208 207
209 if (listed) 208 if (listed)
210 FilterStorage.addSubscription(subscription); 209 FilterStorage.addSubscription(subscription);
211 } 210 }
212 211
213 // The download actually succeeded 212 // The download actually succeeded
214 subscription.lastSuccess = subscription.lastDownload = Math.round( 213 subscription.lastSuccess = subscription.lastDownload = Math.round(
215 Date.now() / MILLIS_IN_SECOND 214 Date.now() / MILLIS_IN_SECOND
216 ); 215 );
217 subscription.downloadStatus = "synchronize_ok"; 216 subscription.downloadStatus = "synchronize_ok";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 request.open("GET", fallbackURL); 327 request.open("GET", fallbackURL);
329 request.overrideMimeType("text/plain"); 328 request.overrideMimeType("text/plain");
330 request.channel.loadFlags = request.channel.loadFlags | 329 request.channel.loadFlags = request.channel.loadFlags |
331 request.channel.INHIBIT_CACHING | 330 request.channel.INHIBIT_CACHING |
332 request.channel.VALIDATE_ALWAYS; 331 request.channel.VALIDATE_ALWAYS;
333 request.addEventListener("load", ev => 332 request.addEventListener("load", ev =>
334 { 333 {
335 if (onShutdown.done) 334 if (onShutdown.done)
336 return; 335 return;
337 336
338 if (!(subscription.url in FilterStorage.knownSubscriptions)) 337 if (!FilterStorage.knownSubscriptions.has(subscription.url))
339 return; 338 return;
340 339
341 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText); 340 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText);
342 if (match && match[1] == "301" && // Moved permanently 341 if (match && match[1] == "301" && // Moved permanently
343 match[2] && /^https?:\/\//i.test(match[2])) 342 match[2] && /^https?:\/\//i.test(match[2]))
344 { 343 {
345 redirectCallback(match[2]); 344 redirectCallback(match[2]);
346 } 345 }
347 else if (match && match[1] == "410") // Gone 346 else if (match && match[1] == "410") // Gone
348 { 347 {
349 let data = "[Adblock]\n" + 348 let data = "[Adblock]\n" +
350 subscription.filters.map(f => f.text).join("\n"); 349 subscription.filters.map(f => f.text).join("\n");
351 redirectCallback("data:text/plain," + encodeURIComponent(data)); 350 redirectCallback("data:text/plain," + encodeURIComponent(data));
352 } 351 }
353 }, false); 352 }, false);
354 request.send(null); 353 request.send(null);
355 } 354 }
356 } 355 }
357 } 356 }
358 }; 357 };
359 Synchronizer.init(); 358 Synchronizer.init();
OLDNEW
« lib/subscriptionClasses.js ('K') | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld