LEFT | RIGHT |
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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 /** | 363 /** |
364 * Loads all subscriptions from the disk. | 364 * Loads all subscriptions from the disk. |
365 * @return {Promise} promise resolved or rejected when loading is complete | 365 * @return {Promise} promise resolved or rejected when loading is complete |
366 */ | 366 */ |
367 loadFromDisk() | 367 loadFromDisk() |
368 { | 368 { |
369 let tryBackup = backupIndex => | 369 let tryBackup = backupIndex => |
370 { | 370 { |
371 return this.restoreBackup(backupIndex, true).then(() => | 371 return this.restoreBackup(backupIndex, true).then(() => |
372 { | 372 { |
373 if (this.subscriptionCount == 0) | 373 if (this.knownSubscriptions.size == 0) |
374 return tryBackup(backupIndex + 1); | 374 return tryBackup(backupIndex + 1); |
375 }).catch(error => | 375 }).catch(error => |
376 { | 376 { |
377 // Give up | 377 // Give up |
378 }); | 378 }); |
379 }; | 379 }; |
380 | 380 |
381 return IO.statFile(this.sourceFile).then(statData => | 381 return IO.statFile(this.sourceFile).then(statData => |
382 { | 382 { |
383 if (!statData.exists) | 383 if (!statData.exists) |
384 { | 384 { |
385 this.firstRun = true; | 385 this.firstRun = true; |
386 return; | 386 return; |
387 } | 387 } |
388 | 388 |
389 let parser = this.importData(true); | 389 let parser = this.importData(true); |
390 return IO.readFromFile(this.sourceFile, parser).then(() => | 390 return IO.readFromFile(this.sourceFile, parser).then(() => |
391 { | 391 { |
392 parser(null); | 392 parser(null); |
393 if (this.subscriptionCount == 0) | 393 if (this.knownSubscriptions.size == 0) |
394 { | 394 { |
395 // No filter subscriptions in the file, this isn't right. | 395 // No filter subscriptions in the file, this isn't right. |
396 throw new Error("No data in the file"); | 396 throw new Error("No data in the file"); |
397 } | 397 } |
398 }); | 398 }); |
399 }).catch(error => | 399 }).catch(error => |
400 { | 400 { |
401 Cu.reportError(error); | 401 Cu.reportError(error); |
402 return tryBackup(1); | 402 return tryBackup(1); |
403 }).then(() => | 403 }).then(() => |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 * @param {Subscription} subscription filter subscription to be removed | 650 * @param {Subscription} subscription filter subscription to be removed |
651 */ | 651 */ |
652 function removeSubscriptionFilters(subscription) | 652 function removeSubscriptionFilters(subscription) |
653 { | 653 { |
654 if (!FilterStorage.knownSubscriptions.has(subscription.url)) | 654 if (!FilterStorage.knownSubscriptions.has(subscription.url)) |
655 return; | 655 return; |
656 | 656 |
657 for (let filter of subscription.filters) | 657 for (let filter of subscription.filters) |
658 filter.removeSubscription(subscription); | 658 filter.removeSubscription(subscription); |
659 } | 659 } |
LEFT | RIGHT |