Bug 1701346 - CACHE: Revert QM_OR_ELSE_WARN to ordinary orElse in BodyGetCacheDir; r=asuth,dom-storage-reviewers,jstutte
authorJan Varga <jvarga@mozilla.com>
Sat, 24 Apr 2021 08:58:31 +0000
changeset 577308 6c58b606570e7a6c1b62503d4c6a9a6ccb4f03b1
parent 577307 238e28e08f352407cbf8767951c11f3e19912bf5
child 577309 e3257012960550fd3d4ff49929a9da2c4a6a1355
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 BodyGetCacheDir; r=asuth,dom-storage-reviewers,jstutte Depends on D113067 Differential Revision: https://phabricator.services.mozilla.com/D113068
dom/cache/FileUtils.cpp
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -84,19 +84,21 @@ Result<NotNull<nsCOMPtr<nsIFile>>, nsres
                    CloneFileAndAppend(aBaseDir, kMorgueDirectory));
 
   // Some file systems have poor performance when there are too many files
   // in a single directory.  Mitigate this issue by spreading the body
   // files out into sub-directories.  We use the last byte of the ID for
   // the name of the sub-directory.
   CACHE_TRY(cacheDir->Append(IntToString(aId.m3[7])));
 
-  QM_TRY(
-      QM_OR_ELSE_WARN(ToResult(cacheDir->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(cacheDir->Create(nsIFile::DIRECTORY_TYPE, 0755))
+             .orElse(ErrToDefaultOkOrErr<NS_ERROR_FILE_ALREADY_EXISTS>));
 
   return WrapNotNullUnchecked(std::move(cacheDir));
 }
 
 }  // namespace
 
 nsresult BodyCreateDir(nsIFile& aBaseDir) {
   CACHE_TRY_INSPECT(const auto& bodyDir,