diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-15 09:52:38 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-15 09:52:38 +0200 |
commit | 8c34d786e46adbcf5496549cb3fe1898761632d4 (patch) | |
tree | 18ffb14b6e8c9e6889474aa54c13fe9ce7b2a330 /services/sync/modules | |
parent | 9d833d769a064d6b0d18813ab03adc2ff2139615 (diff) | |
download | UXP-8c34d786e46adbcf5496549cb3fe1898761632d4.tar UXP-8c34d786e46adbcf5496549cb3fe1898761632d4.tar.gz UXP-8c34d786e46adbcf5496549cb3fe1898761632d4.tar.lz UXP-8c34d786e46adbcf5496549cb3fe1898761632d4.tar.xz UXP-8c34d786e46adbcf5496549cb3fe1898761632d4.zip |
Issue #1208: Fix jsonLoad in Sync's `util.js` to handle errors.
- `OS.Path.join` can throw, so we always need to try/catch it.
- Also do a sanity check to make sure `callback` is defined before use
Diffstat (limited to 'services/sync/modules')
-rw-r--r-- | services/sync/modules/util.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/services/sync/modules/util.js b/services/sync/modules/util.js index 7fd5a7971..73f4d8a80 100644 --- a/services/sync/modules/util.js +++ b/services/sync/modules/util.js @@ -321,10 +321,17 @@ this.Utils = { * could not be loaded, the first argument will be undefined. */ jsonLoad: Task.async(function*(filePath, that, callback) { - let path = OS.Path.join(OS.Constants.Path.profileDir, "weave", filePath + ".json"); + let path; + try { + path = OS.Path.normalize(OS.Path.join(OS.Constants.Path.profileDir, "weave", filePath + ".json")); + } catch (e) { + if (that._log) { + that._log.debug("Path join error: " + e); + } + } if (that._log) { - that._log.trace("Loading json from disk: " + filePath); + that._log.trace("Loading json from disk: " + path); } let json; @@ -341,8 +348,9 @@ this.Utils = { } } } - - callback.call(that, json); + if (callback) { + callback.call(that, json); + } }), /** |