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

Unified Diff: lib/prefs.js

Issue 29731562: Issue 6477 - separate done and error callbacks in IFileSystem::Read (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git@c0a6434596a83383e37678ef3b6ecef00ed6a261
Patch Set: Created March 23, 2018, 10:58 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
Index: lib/prefs.js
diff --git a/lib/prefs.js b/lib/prefs.js
index 15b4efd174ae7e678013414be03fb7b8f64cf659..b9ac2c460c92bbb07b6f3803352c019810f38849 100644
--- a/lib/prefs.js
+++ b/lib/prefs.js
@@ -84,24 +84,27 @@ function defineProperty(key)
function load()
{
- _fileSystem.read(prefsFileName, result =>
+ new Promise((resolve, reject) =>
{
- // prefs.json is expected to be missing, ignore errors reading file
- if (!result.error)
+ _fileSystem.read(prefsFileName, resolve, reject);
+ }).then((result) =>
+ {
+ try
{
- try
- {
- let data = JSON.parse(result.content);
- for (let key in data)
- if (key in defaults)
- values[key] = data[key];
- }
- catch (e)
- {
- Cu.reportError(e);
- }
+ let data = JSON.parse(result.content);
+ for (let key in data)
+ if (key in defaults)
+ values[key] = data[key];
}
-
+ catch (e)
+ {
+ Cu.reportError(e);
+ }
+ }).catch(() =>
+ {
+ // prefs.json is expected to be missing, ignore file reading errors
+ }).then(() =>
+ {
Prefs.initialized = true;
if (typeof Prefs._initListener == "function")
Prefs._initListener();
« no previous file with comments | « lib/io.js ('k') | src/DefaultFileSystem.h » ('j') | src/FileSystemJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld