Created
May 5, 2015 21:59
-
-
Save miketaylr/5c2e477b461235452b6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ddc002d7a6714c4d44afa7b2ce0443c3416d07f4 Mon Sep 17 00:00:00 2001 | |
From: Mike Taylor <[email protected]> | |
Date: Tue, 5 May 2015 16:48:22 -0500 | |
Subject: Check for ua-updates.json in distribution directory. | |
--- | |
netwerk/protocol/http/UserAgentUpdates.jsm | 5 +++-- | |
1 file changed, 3 insertions(+), 2 deletions(-) | |
diff --git a/netwerk/protocol/http/UserAgentUpdates.jsm b/netwerk/protocol/http/UserAgentUpdates.jsm | |
index 95fb07a..1ef201b 100644 | |
--- a/netwerk/protocol/http/UserAgentUpdates.jsm | |
+++ b/netwerk/protocol/http/UserAgentUpdates.jsm | |
@@ -46,16 +46,17 @@ const PREF_UPDATES_ENABLED = PREF_UPDATES + "enabled"; | |
const PREF_UPDATES_URL = PREF_UPDATES + "url"; | |
const PREF_UPDATES_INTERVAL = PREF_UPDATES + "interval"; | |
const PREF_UPDATES_RETRY = PREF_UPDATES + "retry"; | |
const PREF_UPDATES_TIMEOUT = PREF_UPDATES + "timeout"; | |
const PREF_UPDATES_LASTUPDATED = PREF_UPDATES + "lastupdated"; | |
const KEY_PREFDIR = "PrefD"; | |
const KEY_APPDIR = "XCurProcD"; | |
+const KEY_DISTDIR = "XREAppDist"; | |
const FILE_UPDATES = "ua-update.json"; | |
const PREF_APP_DISTRIBUTION = "distribution.id"; | |
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; | |
var gInitialized = false; | |
this.UserAgentUpdates = { | |
@@ -90,18 +91,18 @@ this.UserAgentUpdates = { | |
}, | |
_applySavedUpdate: function() { | |
if (!this._getPref(PREF_UPDATES_ENABLED, false)) { | |
// remove previous overrides | |
this._applyUpdate(null); | |
return; | |
} | |
- // try loading from profile dir, then from app dir | |
- let dirs = [KEY_PREFDIR, KEY_APPDIR]; | |
+ // try loading from profile dir, then from app dir, then distribution dir | |
+ let dirs = [KEY_PREFDIR, KEY_APPDIR, KEY_DISTDIR]; | |
dirs.reduce((prevLoad, dir) => { | |
let file = FileUtils.getFile(dir, [FILE_UPDATES], true).path; | |
// tryNext returns promise to read file under dir and parse it | |
let tryNext = () => OS.File.read(file).then( | |
(bytes) => { | |
let update = JSON.parse(gDecoder.decode(bytes)); | |
if (!update) { | |
throw new Error("invalid update"); | |
-- | |
2.2.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment