Bug 1701346 - CACHE: Revert QM_OR_ELSE_WARN to ordinary orElse in BodyCreateDir; r=asuth,dom-storage-reviewers,jstutte
authorJan Varga <jvarga@mozilla.com>
Sat, 24 Apr 2021 08:58:32 +0000
changeset 577309 e3257012960550fd3d4ff49929a9da2c4a6a1355
parent 577308 6c58b606570e7a6c1b62503d4c6a9a6ccb4f03b1
child 577310 06c8617639a2b45ff1501fa119d48087e1726fa2
push id141828
push userjvarga@mozilla.com
push dateSat, 24 Apr 2021 09:01:07 +0000
treeherderautoland@e32570129605 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, dom-storage-reviewers, jstutte
bugs1701346
milestone90.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 - CACHE: Revert QM_OR_ELSE_WARN to ordinary orElse in BodyCreateDir; r=asuth,dom-storage-reviewers,jstutte Depends on D113068 Differential Revision: https://phabricator.services.mozilla.com/D113069
dom/cache/FileUtils.cpp
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -99,19 +99,21 @@ Result<NotNull<nsCOMPtr<nsIFile>>, nsres
 }
 
 }  // namespace
 
 nsresult BodyCreateDir(nsIFile& aBaseDir) {
   CACHE_TRY_INSPECT(const auto& bodyDir,
                     CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
-  QM_TRY(
-      QM_OR_ELSE_WARN(ToResult(bodyDir->Create(nsIFile::DIRECTORY_TYPE, 0755)),
-                      ErrToDefaultOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS>));
+  // Callers call this function without checking if the directory 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(ToResult(bodyDir->Create(nsIFile::DIRECTORY_TYPE, 0755))
+             .orElse(ErrToDefaultOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS>));
 
   return NS_OK;
 }
 
 nsresult BodyDeleteDir(const QuotaInfo& aQuotaInfo, nsIFile& aBaseDir) {
   CACHE_TRY_INSPECT(const auto& bodyDir,
                     CloneFileAndAppend(aBaseDir, kMorgueDirectory));