Bug 1701346 - QM: Revert QM_OR_ELSE_WARN to ordinary orElse in EnsureDirectory; r=jstutte
authorJan Varga <jvarga@mozilla.com>
Fri, 26 Mar 2021 22:55:18 +0000
changeset 573360 14e56036de5c57f277d0112cbfc742d1e7861fbd
parent 573359 bef51c405b1f0ba979049f544c2de91615fca9a3
child 573361 f3149b974792bb4da3e7fce78afe07e0c1874401
push id139629
push userjstutte@mozilla.com
push dateFri, 26 Mar 2021 23:32:08 +0000
treeherderautoland@14e56036de5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjstutte
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 - QM: Revert QM_OR_ELSE_WARN to ordinary orElse in EnsureDirectory; r=jstutte Differential Revision: https://phabricator.services.mozilla.com/D109987
dom/quota/ActorsParent.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -2384,22 +2384,24 @@ int64_t GetLastModifiedTime(PersistenceT
 
   return timestamp;
 }
 
 // Returns a bool indicating whether the directory was newly created.
 Result<bool, nsresult> EnsureDirectory(nsIFile& aDirectory) {
   AssertIsOnIOThread();
 
+  // Callers call this function without checking if the file already exists
+  // (idempotent usage). QM_OR_ELSE_WARN is not used here since we want to
+  // ignore NS_ERROR_FILE_ALREADY_EXISTS completely.
   QM_TRY_INSPECT(
       const auto& exists,
-      QM_OR_ELSE_WARN(MOZ_TO_RESULT_INVOKE(aDirectory, Create,
-                                           nsIFile::DIRECTORY_TYPE, 0755)
-                          .map([](Ok) { return false; }),
-                      (ErrToOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS, true>)));
+      MOZ_TO_RESULT_INVOKE(aDirectory, Create, nsIFile::DIRECTORY_TYPE, 0755)
+          .map([](Ok) { return false; })
+          .orElse(ErrToOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS, true>));
 
   if (exists) {
     QM_TRY_INSPECT(const bool& isDirectory,
                    MOZ_TO_RESULT_INVOKE(aDirectory, IsDirectory));
     QM_TRY(OkIf(isDirectory), Err(NS_ERROR_UNEXPECTED));
   }
 
   return !exists;