Bug 1701346 - LSNG: Revert QM_OR_ELSE_WARN to ordinary orElse in ExistsAsFile; r=asuth,dom-storage-reviewers,jstutte
authorJan Varga <jvarga@mozilla.com>
Sat, 27 Mar 2021 13:08:07 +0000
changeset 573389 6c1a2d9d4334dd0c28196e817c3d17cc0b3b4ef3
parent 573388 863ab090e28acc62e94caa6c199c7f9dcd395031
child 573390 81f00b36918892ef0a731bc748856f1009a72c81
push id139645
push userjstutte@mozilla.com
push dateSat, 27 Mar 2021 13:10:33 +0000
treeherderautoland@6c1a2d9d4334 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, dom-storage-reviewers, jstutte
bugs1701346
milestone89.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/localstorage/ActorsParent.cpp
--- a/dom/localstorage/ActorsParent.cpp
+++ b/dom/localstorage/ActorsParent.cpp
@@ -956,32 +956,33 @@ Result<nsCOMPtr<nsIFile>, nsresult> GetU
 
 // Checks if aFile exists and is a file. Returns true if it exists and is a
 // file, false if it doesn't exist, and an error if it exists but isn't a file.
 Result<bool, nsresult> ExistsAsFile(nsIFile& aFile) {
   enum class ExistsAsFileResult { DoesNotExist, IsDirectory, IsFile };
 
   // 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));
 
   return res == ExistsAsFileResult::IsFile;
 }
 
 nsresult UpdateUsageFile(nsIFile* aUsageFile, nsIFile* aUsageJournalFile,
                          int64_t aUsage) {