mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
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:
parent
7af1c09409
commit
4913acef81
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user