Bug 345404: fix issue with search update that was causing errors on startup, r=jminta

This commit is contained in:
gavin%gavinsharp.com 2006-07-21 01:30:48 +00:00
parent 60b733da5b
commit fbd6c1d6d7

View File

@ -1484,8 +1484,7 @@ Engine.prototype = {
this._updateURL = child.textContent; this._updateURL = child.textContent;
break; break;
case "UpdateInterval": case "UpdateInterval":
this._updateInterval = parseInt(child.textContent) || this._updateInterval = parseInt(child.textContent);
SEARCH_DEFAULT_UPDATE_INTERVAL;
break; break;
} }
} }
@ -1766,8 +1765,7 @@ Engine.prototype = {
this._queryCharset = searchSection["querycharset"] || this._queryCharset = searchSection["querycharset"] ||
queryCharsetFromCode(searchSection["queryencoding"]); queryCharsetFromCode(searchSection["queryencoding"]);
this._updateInterval = parseInt(browserSection["updatecheckdays"]) || this._updateInterval = parseInt(browserSection["updatecheckdays"]);
SEARCH_DEFAULT_UPDATE_INTERVAL;
this._updateURL = browserSection["update"]; this._updateURL = browserSection["update"];
this._iconUpdateURL = browserSection["updateicon"]; this._iconUpdateURL = browserSection["updateicon"];
@ -1986,6 +1984,11 @@ Engine.prototype = {
return this.__isInAppDir; return this.__isInAppDir;
}, },
get _hasUpdates() {
// Whether or not the engine has an update URL
return !!(this._updateURL || this._iconUpdateURL);
},
get name() { get name() {
return this._name; return this._name;
}, },
@ -2179,18 +2182,20 @@ SearchService.prototype = {
notifyAction(aEngine, SEARCH_ENGINE_ADDED); notifyAction(aEngine, SEARCH_ENGINE_ADDED);
} }
// Schedule the engine's next update, if it isn't already. if (aEngine._hasUpdates) {
if (!engineMetadataService.getAttr(aEngine, "updateexpir")) // Schedule the engine's next update, if it isn't already.
engineUpdateService.scheduleNextUpdate(aEngine); if (!engineMetadataService.getAttr(aEngine, "updateexpir"))
engineUpdateService.scheduleNextUpdate(aEngine);
// We need to save the engine's _dataType, if this is the first time the
// engine is added to the dataStore, since ._dataType isn't persisted // We need to save the engine's _dataType, if this is the first time the
// and will change on the next startup (since the engine will then be XML). // engine is added to the dataStore, since ._dataType isn't persisted
// We need this so that we know how to load any future updates from this // and will change on the next startup (since the engine will then be
// engine. // XML). We need this so that we know how to load any future updates from
if (!engineMetadataService.getAttr(aEngine, "updatedatatype")) // this engine.
engineMetadataService.setAttr(aEngine, "updatedatatype", if (!engineMetadataService.getAttr(aEngine, "updatedatatype"))
aEngine._dataType); engineMetadataService.setAttr(aEngine, "updatedatatype",
aEngine._dataType);
}
}, },
_loadEngines: function SRCH_SVC_loadEngines(aDir) { _loadEngines: function SRCH_SVC_loadEngines(aDir) {
@ -2815,9 +2820,7 @@ var engineUpdateService = {
}, },
scheduleNextUpdate: function eus_scheduleNextUpdate(aEngine) { scheduleNextUpdate: function eus_scheduleNextUpdate(aEngine) {
var interval = aEngine._updateInterval; var interval = aEngine._updateInterval || SEARCH_DEFAULT_UPDATE_INTERVAL;
ENSURE_WARN(interval, "engine has no interval?", Cr.NS_ERROR_UNEXPECTED);
var milliseconds = interval * 86400000; // |interval| is in days var milliseconds = interval * 86400000; // |interval| is in days
engineMetadataService.setAttr(aEngine, "updateexpir", engineMetadataService.setAttr(aEngine, "updateexpir",
Date.now() + milliseconds); Date.now() + milliseconds);
@ -2837,6 +2840,9 @@ var engineUpdateService = {
ULOG("currentTime: " + currentTime); ULOG("currentTime: " + currentTime);
for each (engine in searchService.getEngines({})) { for each (engine in searchService.getEngines({})) {
engine = engine.wrappedJSObject; engine = engine.wrappedJSObject;
if (!engine._hasUpdates)
continue;
ULOG("checking " + engine.name); ULOG("checking " + engine.name);
var expirTime = engineMetadataService.getAttr(engine, "updateexpir"); var expirTime = engineMetadataService.getAttr(engine, "updateexpir");
@ -2846,9 +2852,8 @@ var engineUpdateService = {
"\niconUpdateURL: " + iconUpdateURL); "\niconUpdateURL: " + iconUpdateURL);
var engineExpired = expirTime <= currentTime; var engineExpired = expirTime <= currentTime;
var hasUpdateURLs = !!(updateURL || iconUpdateURL);
if (!expirTime || !engineExpired || !hasUpdateURLs) { if (!expirTime || !engineExpired) {
ULOG("skipping engine"); ULOG("skipping engine");
continue; continue;
} }