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

Unified Diff: lib/subscriptionInit.js

Issue 29760565: Issue 6599 - Detect data corruption of storage.local (Closed)
Patch Set: Rebased Created April 24, 2018, 5:30 p.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 | « lib/prefs.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/subscriptionInit.js
===================================================================
--- a/lib/subscriptionInit.js
+++ b/lib/subscriptionInit.js
@@ -238,38 +238,35 @@
Synchronizer.execute(subscription);
}
- if (!Prefs.suppress_first_run_page)
+ if (firstRun || info.platform == "chromium" &&
+ updatesVersion > Prefs.last_updates_page_displayed)
{
- let page = null;
- if (firstRun)
+ Prefs.set("last_updates_page_displayed", updatesVersion).catch(() =>
{
- page = "firstRun.html";
- }
- // For now we're limiting the updates page to users of
- // Chromium-based browsers to gage its impact
- else if (info.platform == "chromium" &&
- updatesVersion > Prefs.last_updates_page_displayed)
+ exports.dataCorrupted = true;
+ }).then(() =>
{
- page = "updates.html";
- }
-
- if (page)
- {
- browser.tabs.create({url: browser.extension.getURL(page)});
-
- // For new users and users that have already seen this updates page we
- // want to avoid showing it again for subsequent updates.
- Prefs.last_updates_page_displayed = updatesVersion;
- }
+ if (!Prefs.suppress_first_run_page)
+ {
+ let url;
+ if (firstRun || exports.dataCorrupted)
+ url = "firstRun.html";
+ else
+ url = "updates.html";
+ browser.tabs.create({url});
+ }
+ });
}
initNotifications();
}
-Promise.all([FilterNotifier.once("load"),
- Prefs.untilLoaded]).then(detectFirstRun)
- .then(getSubscriptions)
- .then(finishInitialization);
+Promise.all([
+ FilterNotifier.once("load"),
+ Prefs.untilLoaded.catch(() => { exports.dataCorrupted = true; })
+]).then(detectFirstRun)
+ .then(getSubscriptions)
+ .then(finishInitialization);
/**
* Indicates whether the default filter subscriptions have been added
@@ -281,6 +278,13 @@
exports.reinitialized = false;
/**
+ * Indicates whether a data corruption was detcted.
+ *
+ * @type {boolean}
+ */
+exports.dataCorrupted = false;
+
+/**
* Sets a callback that is called with an array of subscriptions to be added
* during initialization. The callback must return an array of subscriptions
* that will effectively be added.
« no previous file with comments | « lib/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld