зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1722777) for causing xpcshell failures.
Backed out changeset 8ea40ee4caf0 (bug 1722777) Backed out changeset 00fa6e16e916 (bug 1722777) Backed out changeset b90cab865ce4 (bug 1722777) Backed out changeset a8344f5044e6 (bug 1722777) Backed out changeset 51a7df84c674 (bug 1722777)
This commit is contained in:
Родитель
c3cbd0c056
Коммит
b18a47ce22
|
@ -8,7 +8,6 @@
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsImportModule.h"
|
#include "nsImportModule.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
#include "nsProfileLock.h"
|
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "SpecialSystemDirectory.h"
|
#include "SpecialSystemDirectory.h"
|
||||||
|
|
||||||
|
@ -171,21 +170,10 @@ nsresult BackgroundTasks::CreateTemporaryProfileDirectoryImpl(
|
||||||
rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(file));
|
rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, getter_AddRefs(file));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCString profilePrefix =
|
|
||||||
nsPrintfCString("%sBackgroundTask-%s-%s", MOZ_APP_VENDOR,
|
|
||||||
aInstallHash.get(), mBackgroundTask.ref().get());
|
|
||||||
|
|
||||||
// Windows file cleanup is unreliable, so let's take a moment to clean up
|
|
||||||
// any prior background task profiles. We can continue if there was an error
|
|
||||||
// as creating a new temporary profile does not require cleaning up the old.
|
|
||||||
rv = RemoveStaleTemporaryProfileDirectories(file, profilePrefix);
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Warning,
|
|
||||||
("Error cleaning up stale temporary profile directories."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The base path is /tmp/[vendor]BackgroundTask-[pathHash]-[taskName].
|
// The base path is /tmp/[vendor]BackgroundTask-[pathHash]-[taskName].
|
||||||
rv = file->AppendNative(profilePrefix);
|
rv = file->AppendNative(nsPrintfCString("%sBackgroundTask-%s-%s",
|
||||||
|
MOZ_APP_VENDOR, aInstallHash.get(),
|
||||||
|
mBackgroundTask.ref().get()));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Create a unique profile directory. This can fail if there are too many
|
// Create a unique profile directory. This can fail if there are too many
|
||||||
|
@ -201,73 +189,6 @@ nsresult BackgroundTasks::CreateTemporaryProfileDirectoryImpl(
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult BackgroundTasks::RemoveStaleTemporaryProfileDirectories(
|
|
||||||
nsIFile* const aRoot, const nsCString& aPrefix) {
|
|
||||||
nsCOMPtr<nsIDirectoryEnumerator> entries;
|
|
||||||
nsresult rv = aRoot->GetDirectoryEntries(getter_AddRefs(entries));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> entry;
|
|
||||||
int removedProfiles = 0;
|
|
||||||
// Limit the number of stale temporary profiles we clean up so that we don't
|
|
||||||
// timeout the background task.
|
|
||||||
const int kMaxRemovedProfiles = 5;
|
|
||||||
|
|
||||||
// Loop over the temporary directory entries, deleting folders matching our
|
|
||||||
// profile prefix. Continue if there is an error interacting with the entry to
|
|
||||||
// more reliably make progress on cleaning up stale temporary profiles.
|
|
||||||
while (removedProfiles < kMaxRemovedProfiles &&
|
|
||||||
NS_SUCCEEDED(rv = entries->GetNextFile(getter_AddRefs(entry))) &&
|
|
||||||
entry) {
|
|
||||||
nsCString entryName;
|
|
||||||
rv = entry->GetNativeLeafName(entryName);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find profile folders matching our prefix.
|
|
||||||
if (aPrefix.Compare(entryName.get(), false, aPrefix.Length()) != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the profile is locked. If successful drop the lock so we can
|
|
||||||
// delete the folder. Background tasks' temporary profiles are not reused or
|
|
||||||
// remembered once released, so we don't need to hold this lock while
|
|
||||||
// deleting it.
|
|
||||||
nsProfileLock lock;
|
|
||||||
if (NS_FAILED(lock.Lock(entry, nullptr)) || NS_FAILED(lock.Unlock())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = entry->Remove(true);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Warning)) {
|
|
||||||
nsAutoString path;
|
|
||||||
if (NS_SUCCEEDED(entry->GetPath(path))) {
|
|
||||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Warning,
|
|
||||||
("Error removing stale temporary profile directory: %s",
|
|
||||||
NS_LossyConvertUTF16toASCII(path).get()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MOZ_LOG_TEST(sBackgroundTasksLog, mozilla::LogLevel::Info)) {
|
|
||||||
nsAutoString path;
|
|
||||||
if (NS_SUCCEEDED(entry->GetPath(path))) {
|
|
||||||
MOZ_LOG(sBackgroundTasksLog, mozilla::LogLevel::Info,
|
|
||||||
("Removed stale temporary profile directory: %s",
|
|
||||||
NS_LossyConvertUTF16toASCII(path).get()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
removedProfiles++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult BackgroundTasks::GetIsBackgroundTaskMode(bool* result) {
|
nsresult BackgroundTasks::GetIsBackgroundTaskMode(bool* result) {
|
||||||
*result = mBackgroundTask.isSome();
|
*result = mBackgroundTask.isSome();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
|
@ -75,13 +75,6 @@ class BackgroundTasks final : public nsIBackgroundTasks {
|
||||||
nsresult CreateTemporaryProfileDirectoryImpl(const nsCString& aInstallHash,
|
nsresult CreateTemporaryProfileDirectoryImpl(const nsCString& aInstallHash,
|
||||||
nsIFile** aFile);
|
nsIFile** aFile);
|
||||||
|
|
||||||
/*
|
|
||||||
* Iterates children of `aRoot` and removes unlocked profiles matching
|
|
||||||
* `aPrefix`.
|
|
||||||
*/
|
|
||||||
static nsresult RemoveStaleTemporaryProfileDirectories(
|
|
||||||
nsIFile* const aRoot, const nsCString& aPrefix);
|
|
||||||
|
|
||||||
virtual ~BackgroundTasks() = default;
|
virtual ~BackgroundTasks() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,6 @@ EXTRA_JS_MODULES.backgroundtasks += [
|
||||||
"BackgroundTask_success.jsm",
|
"BackgroundTask_success.jsm",
|
||||||
]
|
]
|
||||||
|
|
||||||
LOCAL_INCLUDES += [
|
|
||||||
"../../profile",
|
|
||||||
]
|
|
||||||
|
|
||||||
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
|
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
|
||||||
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
|
XPCSHELL_TESTS_MANIFESTS += ["tests/xpcshell/xpcshell.ini"]
|
||||||
|
|
||||||
|
|
|
@ -2303,11 +2303,6 @@ nsLocalFile::Remove(bool aRecursive) {
|
||||||
|
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
if (aRecursive) {
|
if (aRecursive) {
|
||||||
// WARNING: neither the `SHFileOperation` nor `IFileOperation` APIs are
|
|
||||||
// appropriate here as neither handle long path names, i.e. paths prefixed
|
|
||||||
// with `\\?\` or longer than 260 characters on Windows 10+ system with
|
|
||||||
// long paths enabled.
|
|
||||||
|
|
||||||
RefPtr<nsDirEnumerator> dirEnum = new nsDirEnumerator();
|
RefPtr<nsDirEnumerator> dirEnum = new nsDirEnumerator();
|
||||||
|
|
||||||
rv = dirEnum->Init(this);
|
rv = dirEnum->Init(this);
|
||||||
|
@ -2315,11 +2310,16 @@ nsLocalFile::Remove(bool aRecursive) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> file;
|
bool more = false;
|
||||||
while (NS_SUCCEEDED(dirEnum->GetNextFile(getter_AddRefs(file))) && file) {
|
while (NS_SUCCEEDED(dirEnum->HasMoreElements(&more)) && more) {
|
||||||
|
nsCOMPtr<nsISupports> item;
|
||||||
|
dirEnum->GetNext(getter_AddRefs(item));
|
||||||
|
nsCOMPtr<nsIFile> file = do_QueryInterface(item);
|
||||||
|
if (file) {
|
||||||
file->Remove(aRecursive);
|
file->Remove(aRecursive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (RemoveDirectoryW(mWorkingPath.get()) == 0) {
|
if (RemoveDirectoryW(mWorkingPath.get()) == 0) {
|
||||||
return ConvertWinError(GetLastError());
|
return ConvertWinError(GetLastError());
|
||||||
}
|
}
|
||||||
|
@ -3080,8 +3080,8 @@ nsLocalFile::Contains(nsIFile* aInFile, bool* aResult) {
|
||||||
aInFile->GetPath(inFilePath);
|
aInFile->GetPath(inFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that the |aInFile|'s path has a trailing separator.
|
// make sure that the |aInFile|'s path has a trailing separator.
|
||||||
if (inFilePath.Length() > myFilePathLen &&
|
if (inFilePath.Length() >= myFilePathLen &&
|
||||||
inFilePath[myFilePathLen] == L'\\') {
|
inFilePath[myFilePathLen] == L'\\') {
|
||||||
if (_wcsnicmp(myFilePath.get(), inFilePath.get(), myFilePathLen) == 0) {
|
if (_wcsnicmp(myFilePath.get(), inFilePath.get(), myFilePathLen) == 0) {
|
||||||
*aResult = true;
|
*aResult = true;
|
||||||
|
|
|
@ -134,6 +134,11 @@ function testSymLinks(testDir, relative) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_test() {
|
function run_test() {
|
||||||
|
// Skip this test on Windows
|
||||||
|
if (mozinfo.os == "win") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var testDir = CWD;
|
var testDir = CWD;
|
||||||
testDir.append("test_symlinks");
|
testDir.append("test_symlinks");
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,6 @@ skip-if = os == "android"
|
||||||
[test_streams.js]
|
[test_streams.js]
|
||||||
[test_seek_multiplex.js]
|
[test_seek_multiplex.js]
|
||||||
[test_stringstream.js]
|
[test_stringstream.js]
|
||||||
skip-if = os == "win"
|
|
||||||
[test_symlinks.js]
|
[test_symlinks.js]
|
||||||
# Bug 676998: test fails consistently on Android
|
# Bug 676998: test fails consistently on Android
|
||||||
fail-if = os == "android"
|
fail-if = os == "android"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче