| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  437       return this.saveToDisk(); |  437       return this.saveToDisk(); | 
|  438     }); |  438     }); | 
|  439   }, |  439   }, | 
|  440  |  440  | 
|  441   /** |  441   /** | 
|  442    * Generator serializing filter data and yielding it line by line. |  442    * Generator serializing filter data and yielding it line by line. | 
|  443    */ |  443    */ | 
|  444   *exportData() |  444   *exportData() | 
|  445   { |  445   { | 
|  446     // Do not persist external subscriptions |  446     // Do not persist external subscriptions | 
|  447     let subscriptions = [...this.knownSubscriptions.values()].filter( |  447     let subscriptions = []; | 
|  448       s => !(s instanceof ExternalSubscription) |  448     for (let subscription of this.subscriptions()) | 
|  449     ); |  449     { | 
 |  450       if (!(subscription instanceof ExternalSubscription)) | 
 |  451         subscriptions.push(subscription); | 
 |  452     } | 
|  450  |  453  | 
|  451     yield "# Adblock Plus preferences"; |  454     yield "# Adblock Plus preferences"; | 
|  452     yield "version=" + formatVersion; |  455     yield "version=" + formatVersion; | 
|  453  |  456  | 
|  454     let saved = new Set(); |  457     let saved = new Set(); | 
|  455     let buf = []; |  458     let buf = []; | 
|  456  |  459  | 
|  457     // Save subscriptions |  460     // Save subscriptions | 
|  458     for (let subscription of subscriptions) |  461     for (let subscription of subscriptions) | 
|  459     { |  462     { | 
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  647  * @param {Subscription} subscription filter subscription to be removed |  650  * @param {Subscription} subscription filter subscription to be removed | 
|  648  */ |  651  */ | 
|  649 function removeSubscriptionFilters(subscription) |  652 function removeSubscriptionFilters(subscription) | 
|  650 { |  653 { | 
|  651   if (!FilterStorage.knownSubscriptions.has(subscription.url)) |  654   if (!FilterStorage.knownSubscriptions.has(subscription.url)) | 
|  652     return; |  655     return; | 
|  653  |  656  | 
|  654   for (let filter of subscription.filters) |  657   for (let filter of subscription.filters) | 
|  655     filter.removeSubscription(subscription); |  658     filter.removeSubscription(subscription); | 
|  656 } |  659 } | 
| LEFT | RIGHT |