Bug 1401236 - Don't reread already loaded data in `JSONFile#load`. r?Gijs
MozReview-Commit-ID: AHD5G453GHM
--- a/toolkit/modules/JSONFile.jsm
+++ b/toolkit/modules/JSONFile.jsm
@@ -174,16 +174,20 @@ JSONFile.prototype = {
* Loads persistent data from the file to memory.
*
* @return {Promise}
* @resolves When the operation finished successfully.
* @rejects JavaScript exception when dataPostProcessor fails. It never fails
* if there is no dataPostProcessor.
*/
async load() {
+ if (this.dataReady) {
+ return;
+ }
+
let data = {};
try {
let bytes = await OS.File.read(this.path, this._options);
// If synchronous loading happened in the meantime, exit now.
if (this.dataReady) {
return;