Bug 1594075 - P1 - Ignore the unknown directories in origin directories; r=janv

Differential Revision: https://phabricator.services.mozilla.com/D51873

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Tung 2019-12-18 15:50:18 +00:00
Родитель d7353ef739
Коммит 09c32538fb
2 изменённых файлов: 62 добавлений и 83 удалений

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

@ -5180,10 +5180,6 @@ nsresult QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
Client::Type clientType;
bool ok = Client::TypeFromText(leafName, clientType, fallible);
if (!ok) {
UNKNOWN_FILE_WARNING(leafName);
REPORT_TELEMETRY_INIT_ERR(kQuotaInternalError, Ori_UnexpectedClient);
RECORD_IN_NIGHTLY(statusKeeper, NS_ERROR_UNEXPECTED);
// Our upgrade process should have attempted to delete the deprecated
// client directory and failed to upgrade if it could not be deleted. So
// if we're here, either a) there's a bug in our code or b) a user copied
@ -5200,10 +5196,13 @@ nsresult QuotaManager::InitializeOrigin(PersistenceType aPersistenceType,
CONTINUE_IN_NIGHTLY_RETURN_IN_OTHERS(rv);
}
MOZ_DIAGNOSTIC_ASSERT(true, "Found a deprecated client");
MOZ_DIAGNOSTIC_ASSERT(false, "Found a deprecated client");
}
CONTINUE_IN_NIGHTLY_RETURN_IN_OTHERS(NS_ERROR_UNEXPECTED);
// Unknown directories during initialization are now allowed. Just warn if
// we find them.
UNKNOWN_FILE_WARNING(leafName);
continue;
}
UsageInfo usageInfo;
@ -9015,10 +9014,9 @@ nsresult QuotaUsageRequestBase::GetUsageForOrigin(
Client::Type clientType;
bool ok = Client::TypeFromText(leafName, clientType, fallible);
if (!ok) {
// Unknown directories during getting usage for an origin (even for an
// uninitialized origin) are now allowed. Just warn if we find them.
UNKNOWN_FILE_WARNING(leafName);
if (!initialized) {
return NS_ERROR_UNEXPECTED;
}
continue;
}

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

@ -29,7 +29,7 @@ function* testSteps() {
dir: false,
};
const unknownClient = {
const unknownOriginDirectory = {
path: "storage/permanent/chrome/foo",
dir: true,
};
@ -94,6 +94,7 @@ function* testSteps() {
"Initialization succeeded even though there are unknown files in " +
"repositories"
);
ok(request.result === true, "The origin directory was created");
info("Clearing origin");
@ -109,7 +110,10 @@ function* testSteps() {
ok(request.resultCode == NS_OK, "Clearing succeeded");
info("Stage 3 - Testing unknown origin files found during origin init");
info(
"Stage 3 - Testing unknown origin files and unknown origin directories " +
"found during origin init"
);
info("Initializing");
@ -118,9 +122,10 @@ function* testSteps() {
ok(request.resultCode == NS_OK, "Initialization succeeded");
for (let unknownFile of [unknownOriginFile, unknownOriginDirectory]) {
info("Creating unknown file");
file = createFile(unknownOriginFile);
file = createFile(unknownFile);
info("Initializing origin");
@ -129,9 +134,10 @@ function* testSteps() {
ok(
request.resultCode == NS_OK,
"Initialization succeeded even though there are unknown files in origin " +
"directories"
"Initialization succeeded even though there are unknown files or " +
"directories in origin directories"
);
ok(request.result === false, "The origin directory wasn't created");
info("Getting usage");
@ -140,38 +146,12 @@ function* testSteps() {
ok(
request.resultCode == NS_OK,
"Get usage succeeded even though there are unknown files in origin " +
"directories"
"Get usage succeeded even though there are unknown files or directories" +
"in origin directories"
);
info("Clearing origin");
request = clearChromeOrigin(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Clearing succeeded");
info("Stage 4 - Testing unknown client files found during origin init");
info("Creating unknown file");
file = createFile(unknownClient);
info("Initializing origin");
request = initStorageAndChromeOrigin("persistent", continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_ERROR_UNEXPECTED, "Initialization failed");
ok(request.result === null, "The request result is null");
info("Getting usage");
request = getCurrentUsage(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_ERROR_UNEXPECTED, "Initialization failed");
ok(request.result === null, "The request result is null");
ok(request.result, "The request result is not null");
ok(request.result.usage === 0, "The usage was 0");
ok(request.result.fileUsage === 0, "The fileUsage was 0");
file.remove(/* recursive */ false);
@ -181,13 +161,9 @@ function* testSteps() {
yield undefined;
ok(request.resultCode == NS_OK, "Get usage succeeded");
info("Clearing origin");
request = clearChromeOrigin(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Clearing succeeded");
ok(request.result, "The request result is not null");
ok(request.result.usage === 0, "The usage was 0");
ok(request.result.fileUsage === 0, "The fileUsage was 0");
info("Initializing origin");
@ -195,8 +171,9 @@ function* testSteps() {
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
ok(request.result === false, "The origin directory wasn't created");
file = createFile(unknownClient);
file = createFile(unknownFile);
info("Getting usage");
@ -204,6 +181,9 @@ function* testSteps() {
yield undefined;
ok(request.resultCode == NS_OK, "Get usage succeeded");
ok(request.result, "The request result is not null");
ok(request.result.usage === 0, "The usage was 0");
ok(request.result.fileUsage === 0, "The fileUsage was 0");
info("Clearing origin");
@ -211,6 +191,7 @@ function* testSteps() {
yield undefined;
ok(request.resultCode == NS_OK, "Clearing succeeded");
}
info("Clearing");