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

Unified Diff: lib/filterStorage.js

Issue 29402582: Issue 5098 - Expose FilterStorage initialization state (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Fixed description Created April 5, 2017, 7:16 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/filterStorage_readwrite.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -42,16 +42,22 @@ let formatVersion = 4;
/**
* This class reads user's filters from disk, manages them in memory
* and writes them back.
* @class
*/
let FilterStorage = exports.FilterStorage =
{
/**
+ * Will be set to true after the initial loadFromDisk() call completes.
+ * @type {boolean}
+ */
+ initialized: false,
+
+ /**
* Version number of the patterns.ini format used.
* @type {number}
*/
get formatVersion()
{
return formatVersion;
},
@@ -458,16 +464,18 @@ let FilterStorage = exports.FilterStorag
{
let readFile = () =>
{
let parser = {
process: this.importData()
};
IO.readFromFile(this.sourceFile, parser, readFromFileException =>
{
+ this.initialized = true;
+
if (!readFromFileException && this.subscriptions.length == 0)
{
// No filter subscriptions in the file, this isn't right.
readFromFileException = new Error("No data in the file");
}
if (readFromFileException)
Cu.reportError(readFromFileException);
@@ -489,16 +497,17 @@ let FilterStorage = exports.FilterStorag
});
};
IO.statFile(this.sourceFile, (statError, statData) =>
{
if (statError || !statData.exists)
{
this.firstRun = true;
+ this.initialized = true;
FilterNotifier.triggerListeners("load");
}
else
readFile();
});
},
/**
« no previous file with comments | « no previous file | test/filterStorage_readwrite.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld