Index: lib/filterStorage.js |
=================================================================== |
--- a/lib/filterStorage.js |
+++ b/lib/filterStorage.js |
@@ -371,62 +371,68 @@ let FilterStorage = exports.FilterStorag |
sourceFile = sourceFile.clone(); |
sourceFile.leafName = part1 + "-backup" + (++backupIndex) + part2; |
IO.statFile(sourceFile, function(e, statData) |
{ |
if (!e && statData.exists) |
readFile(sourceFile, backupIndex); |
+ else |
+ doneReading(parser); |
}); |
TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); |
return; |
} |
} |
- |
- // Old special groups might have been converted, remove them if they are empty |
- let specialMap = {"~il~": true, "~wl~": true, "~fl~": true, "~eh~": true}; |
- let knownSubscriptions = {__proto__: null}; |
- for (let i = 0; i < parser.subscriptions.length; i++) |
- { |
- let subscription = parser.subscriptions[i]; |
- if (subscription instanceof SpecialSubscription && subscription.filters.length == 0 && subscription.url in specialMap) |
- parser.subscriptions.splice(i--, 1); |
- else |
- knownSubscriptions[subscription.url] = subscription; |
- } |
- |
- this.fileProperties = parser.fileProperties; |
- this.subscriptions = parser.subscriptions; |
- this.knownSubscriptions = knownSubscriptions; |
- Filter.knownFilters = parser.knownFilters; |
- Subscription.knownSubscriptions = parser.knownSubscriptions; |
- |
- if (parser.userFilters) |
- { |
- for (let i = 0; i < parser.userFilters.length; i++) |
- { |
- let filter = Filter.fromText(parser.userFilters[i]); |
- this.addFilter(filter, null, undefined, true); |
- } |
- } |
- TimeLine.log("Initializing data done, triggering observers") |
- |
- this._loading = false; |
- FilterNotifier.triggerListeners("load"); |
- |
- if (sourceFile != this.sourceFile) |
- this.saveToDisk(); |
- |
- TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); |
+ doneReading(parser); |
}.bind(this), "FilterStorageRead"); |
TimeLine.leave("FilterStorage.loadFromDisk() <- readFile()", "FilterStorageRead"); |
}.bind(this); |
+ var doneReading = function(parser) |
+ { |
+ // Old special groups might have been converted, remove them if they are empty |
+ let specialMap = {"~il~": true, "~wl~": true, "~fl~": true, "~eh~": true}; |
+ let knownSubscriptions = {__proto__: null}; |
+ for (let i = 0; i < parser.subscriptions.length; i++) |
+ { |
+ let subscription = parser.subscriptions[i]; |
+ if (subscription instanceof SpecialSubscription && subscription.filters.length == 0 && subscription.url in specialMap) |
+ parser.subscriptions.splice(i--, 1); |
+ else |
+ knownSubscriptions[subscription.url] = subscription; |
+ } |
+ |
+ this.fileProperties = parser.fileProperties; |
+ this.subscriptions = parser.subscriptions; |
+ this.knownSubscriptions = knownSubscriptions; |
+ Filter.knownFilters = parser.knownFilters; |
+ Subscription.knownSubscriptions = parser.knownSubscriptions; |
+ |
+ if (parser.userFilters) |
+ { |
+ for (let i = 0; i < parser.userFilters.length; i++) |
+ { |
+ let filter = Filter.fromText(parser.userFilters[i]); |
+ this.addFilter(filter, null, undefined, true); |
+ } |
+ } |
+ TimeLine.log("Initializing data done, triggering observers") |
+ |
+ this._loading = false; |
+ FilterNotifier.triggerListeners("load"); |
+ |
+ if (sourceFile != this.sourceFile) |
+ this.saveToDisk(); |
+ |
+ TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); |
+ }.bind(this); |
+ |
let startRead = function(file) |
{ |
this._loading = true; |
readFile(file, 0); |
}.bind(this); |
let explicitFile; |
if (sourceFile) |