Additional logging for Bug 835197 - Intermittent test_0201_app_launch_apply_update.js, test_0202_app_launch_apply_update_dirlocked.js, test_0203_app_launch_apply_update.js [Exception... 'Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFile.copyTo]'. r=bbondy

This commit is contained in:
Robert Strong 2013-02-01 11:36:08 -08:00
Родитель c2265b7155
Коммит 2257ced8dd
7 изменённых файлов: 83 добавлений и 6 удалений

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

@ -470,6 +470,83 @@ if (IS_WIN) {
}
}
/**
* Copies a directory and its children. First it tries nsIFile::CopyTo on the
* source directory and if that fails it will fall back to recursing.
*
* @param aSrcDir
* nsIFile for the source directory to be copied from.
* @param aDestDir
* nsIFile for the destination directory parent.
* @param aDestLeafName
* the destination directory name.
*/
function copyDirRecursive(aSrcDir, aDestDir, aDestLeafName) {
try {
aSrcDir.copyTo(aDestDir, aDestLeafName);
return;
}
catch (e) {
logTestInfo("copyTo error - src path: " + aSrcDir.path + ", dest path: " +
aDestDir.path + ", dir name: " + aDestLeafName +
", exception: " + e);
}
let destDir = aDestDir.clone();
destDir.append(aDestLeafName);
if (!destDir.exists()) {
try {
destDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
}
catch (e) {
logTestInfo("unable to create directory, path: " + destDir.path +
", exception: " + e);
do_throw(e);
}
}
var dirEntries = aSrcDir.directoryEntries;
while (dirEntries.hasMoreElements()) {
let entry = dirEntries.getNext().QueryInterface(AUS_Ci.nsIFile);
if (entry.isDirectory()) {
copyDirRecursive(entry, destDir, entry.leafName);
}
else {
let destFile = destDir.clone();
destFile.append(entry.leafName);
if (destFile.exists()) {
try {
destFile.remove(false);
}
catch (e) {
logTestInfo("unable to remove file, path: " + destFile.path +
", exception: " + e);
let bakFile = destDir.clone();
bakFile.append(entry.leafName + ".bak");
logTestInfo("attempting moveTo of file, src path: " + destFile.path +
", dest path: " + bakFile.path + ", exception: " + e);
try {
destFile.moveTo(destDir, bakFile.leafName);
}
catch (e) {
logTestInfo("unable to move file, src path: " + destFile.path +
", dest path: " + bakFile.path + ", exception: " + e);
do_throw(e);
}
}
}
try {
entry.copyTo(destDir, entry.leafName);
}
catch (e) {
logTestInfo("unable to copy file, src path: " + entry.path +
", dest path: " + destFile.path + ", exception: " + e);
do_throw(e);
}
}
}
}
/**
* Helper function for updater tests for launching the updater binary to apply
* a mar file.

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

@ -303,7 +303,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;

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

@ -238,7 +238,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;

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

@ -332,7 +332,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;

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

@ -309,7 +309,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;

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

@ -247,7 +247,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;

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

@ -335,7 +335,7 @@ function adjustPathsOnWindows() {
tmpDir.append("ExecutableDir.tmp");
tmpDir.createUnique(tmpDir.DIRECTORY_TYPE, 0755);
let procDir = getCurrentProcessDir();
procDir.copyTo(tmpDir, "bin");
copyDirRecursive(procDir, tmpDir, "bin");
let newDir = tmpDir.clone();
newDir.append("bin");
gWindowsBinDir = newDir;