fix for bug #375710 and bug #371649Firefox can "software downgrade" from 2.0.0.3 to 2.0.0.2. r=bsmedberg

This commit is contained in:
sspitzer@mozilla.org 2007-04-12 15:07:19 -07:00
Родитель 250b120fee
Коммит 6a39468669
2 изменённых файлов: 66 добавлений и 4 удалений

Просмотреть файл

@ -129,6 +129,36 @@ function openFileOutputStream(file, flags) {
return stream;
}
/**
* Determine if a file is a child of another file. Needed because
* nsILocalFile.contains() has problems with short vs. long paths
* see bug #375710 for more details
*
* @param aParent (nsILocalFile)
* @param aChild (nsILocalFile)
* @return true if aChild is a child of aParent. Will also return
* true if aChild is same as aParent
*/
function canonicalRecursiveContains(aParent, aChild)
{
try {
var current = aChild;
while (current) {
if (aParent.equals(current))
return true;
var newCurrent = current.parent;
if (newCurrent.equals(current))
return false;
current = newCurrent;
}
}
catch (ex) {
}
return false;
}
//-----------------------------------------------------------------------------
const PREFIX_FILE = "File: ";
@ -192,7 +222,7 @@ InstallLogWriter.prototype = {
.getService(Components.interfaces.nsIProperties);
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
Components.interfaces.nsILocalFile);
if (programFilesDir.contains(updRoot, true)) {
if (canonicalRecursiveContains(programFilesDir, updRoot)) {
var relativePath = updRoot.QueryInterface(Components.interfaces.nsILocalFile).
getRelativeDescriptor(programFilesDir);
var userLocalDir = fileLocator.get(KEY_LOCALDATA,

Просмотреть файл

@ -217,6 +217,38 @@ function getUpdateDir(pathArray) {
return getDirInternal(KEY_APPDIR, pathArray, true, true);
}
#ifdef XP_WIN
/**
* Determine if a file is a child of another file. Needed because
* nsILocalFile.contains() has problems with short vs. long paths
* see bug #375710 for more details
*
* @param aParent (nsILocalFile)
* @param aChild (nsILocalFile)
* @return true if aChild is a child of aParent. Will also return
* true if aChild is same as aParent
*/
function canonicalRecursiveContains(aParent, aChild)
{
try {
var current = aChild;
while (current) {
if (aParent.equals(current))
return true;
var newCurrent = current.parent;
if (newCurrent.equals(current))
return false;
current = newCurrent;
}
}
catch (ex) {
}
return false;
}
#endif
/**
* Gets the specified directory at the speciifed hierarchy under a
* Directory Service key.
@ -242,7 +274,7 @@ function getDirInternal(key, pathArray, shouldCreate, update) {
if (update) {
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
Components.interfaces.nsILocalFile);
if (programFilesDir.contains(dir, true)) {
if (canonicalRecursiveContains(programFilesDir, dir)) {
var relativePath = dir.getRelativeDescriptor(programFilesDir);
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
Components.interfaces.nsILocalFile).parent;
@ -358,7 +390,7 @@ function getUpdatesDir(key) {
#ifdef XP_WIN
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
Components.interfaces.nsILocalFile);
if (programFilesDir.contains(appDir, true)) {
if (canonicalRecursiveContains(programFilesDir, appDir)) {
var relativePath = appDir.getRelativeDescriptor(programFilesDir);
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
Components.interfaces.nsILocalFile).parent;
@ -2041,7 +2073,7 @@ Checker.prototype = {
// Always stop the current check
if (this._request)
this._request.abort();
const nsIUpdateChecker = Components.interfaces.nsIUpdateChecker;
switch (duration) {
case nsIUpdateChecker.CURRENT_SESSION: