зеркало из https://github.com/mozilla/pjs.git
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:
Родитель
250b120fee
Коммит
6a39468669
|
@ -129,6 +129,36 @@ function openFileOutputStream(file, flags) {
|
||||||
return stream;
|
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: ";
|
const PREFIX_FILE = "File: ";
|
||||||
|
@ -192,7 +222,7 @@ InstallLogWriter.prototype = {
|
||||||
.getService(Components.interfaces.nsIProperties);
|
.getService(Components.interfaces.nsIProperties);
|
||||||
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
||||||
Components.interfaces.nsILocalFile);
|
Components.interfaces.nsILocalFile);
|
||||||
if (programFilesDir.contains(updRoot, true)) {
|
if (canonicalRecursiveContains(programFilesDir, updRoot)) {
|
||||||
var relativePath = updRoot.QueryInterface(Components.interfaces.nsILocalFile).
|
var relativePath = updRoot.QueryInterface(Components.interfaces.nsILocalFile).
|
||||||
getRelativeDescriptor(programFilesDir);
|
getRelativeDescriptor(programFilesDir);
|
||||||
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
||||||
|
|
|
@ -217,6 +217,38 @@ function getUpdateDir(pathArray) {
|
||||||
return getDirInternal(KEY_APPDIR, pathArray, true, true);
|
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
|
* Gets the specified directory at the speciifed hierarchy under a
|
||||||
* Directory Service key.
|
* Directory Service key.
|
||||||
|
@ -242,7 +274,7 @@ function getDirInternal(key, pathArray, shouldCreate, update) {
|
||||||
if (update) {
|
if (update) {
|
||||||
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
||||||
Components.interfaces.nsILocalFile);
|
Components.interfaces.nsILocalFile);
|
||||||
if (programFilesDir.contains(dir, true)) {
|
if (canonicalRecursiveContains(programFilesDir, dir)) {
|
||||||
var relativePath = dir.getRelativeDescriptor(programFilesDir);
|
var relativePath = dir.getRelativeDescriptor(programFilesDir);
|
||||||
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
||||||
Components.interfaces.nsILocalFile).parent;
|
Components.interfaces.nsILocalFile).parent;
|
||||||
|
@ -358,7 +390,7 @@ function getUpdatesDir(key) {
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
var programFilesDir = fileLocator.get(KEY_PROGRAMFILES,
|
||||||
Components.interfaces.nsILocalFile);
|
Components.interfaces.nsILocalFile);
|
||||||
if (programFilesDir.contains(appDir, true)) {
|
if (canonicalRecursiveContains(programFilesDir, appDir)) {
|
||||||
var relativePath = appDir.getRelativeDescriptor(programFilesDir);
|
var relativePath = appDir.getRelativeDescriptor(programFilesDir);
|
||||||
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
var userLocalDir = fileLocator.get(KEY_LOCALDATA,
|
||||||
Components.interfaces.nsILocalFile).parent;
|
Components.interfaces.nsILocalFile).parent;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче