Bug 1701346 - LSNG: Revert QM_OR_ELSE_WARN to ordinary orElse in ExistsAsFile; r=asuth,dom-storage-reviewers,jstutte

Depends on D109991

Differential Revision: https://phabricator.services.mozilla.com/D109992
This commit is contained in:
Jan Varga 2021-03-27 13:08:07 +00:00
parent 7af1c09409
commit 4913acef81

View File

@ -961,22 +961,23 @@ Result<bool, nsresult> ExistsAsFile(nsIFile& aFile) {
// This is an optimization to check both properties in one OS case, rather
// than calling Exists first, and then IsDirectory. IsDirectory also checks if
// the path exists.
// the path exists. QM_OR_ELSE_WARN is not used here since we want to ignore
// NS_ERROR_FILE_NOT_FOUND/NS_ERROR_FILE_TARGET_DOES_NOT_EXIST completely.
LS_TRY_INSPECT(
const auto& res,
QM_OR_ELSE_WARN(
MOZ_TO_RESULT_INVOKE(aFile, IsDirectory)
.map([](const bool isDirectory) {
return isDirectory ? ExistsAsFileResult::IsDirectory
: ExistsAsFileResult::IsFile;
}),
([](const nsresult rv) -> Result<ExistsAsFileResult, nsresult> {
if (rv != NS_ERROR_FILE_NOT_FOUND &&
rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
return Err(rv);
}
return ExistsAsFileResult::DoesNotExist;
})));
MOZ_TO_RESULT_INVOKE(aFile, IsDirectory)
.map([](const bool isDirectory) {
return isDirectory ? ExistsAsFileResult::IsDirectory
: ExistsAsFileResult::IsFile;
})
.orElse(
[](const nsresult rv) -> Result<ExistsAsFileResult, nsresult> {
if (rv != NS_ERROR_FILE_NOT_FOUND &&
rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
return Err(rv);
}
return ExistsAsFileResult::DoesNotExist;
}));
LS_TRY(OkIf(res != ExistsAsFileResult::IsDirectory), Err(NS_ERROR_FAILURE));