Bug 1398231 - P1: Make file exist check before assertion. r=bkelly
authorTom Tung <shes050117@gmail.com>
Sat, 09 Sep 2017 09:30:05 +0800
changeset 429665 e999670eb2951a8b84b221eb7ce20544a5f54b88
parent 429664 ad946b2319fc897cc0b09640d51db6a5bc869e28
child 429666 89abc58564c87354f3d135c00afccab5aaa0d510
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1398231
milestone57.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 1398231 - P1: Make file exist check before assertion. r=bkelly MozReview-Commit-ID: 8t7P97Ttrv1
dom/cache/FileUtils.cpp
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -781,18 +781,20 @@ LockedUpdateDirectoryPaddingFile(nsIFile
                                  const bool aTemporaryFileExist)
 {
   MOZ_DIAGNOSTIC_ASSERT(aBaseDir);
   MOZ_DIAGNOSTIC_ASSERT(aConn);
   MOZ_DIAGNOSTIC_ASSERT(aIncreaseSize >= 0);
   MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
 
   int64_t currentPaddingSize = 0;
-  nsresult rv = LockedDirectoryPaddingGet(aBaseDir, &currentPaddingSize);
-  if (NS_WARN_IF(NS_FAILED(rv)) || aTemporaryFileExist) {
+  nsresult rv = NS_OK;
+  if (aTemporaryFileExist ||
+      NS_WARN_IF(NS_FAILED(rv =
+        LockedDirectoryPaddingGet(aBaseDir, &currentPaddingSize)))) {
     // Fail to read padding size from the dir padding file, so try to restore.
     if (rv != NS_ERROR_FILE_NOT_FOUND &&
         rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
       // Not delete the temporary padding file here, because we're going to
       // overwrite it below anyway.
       rv = LockedDirectoryPaddingDeleteFile(aBaseDir, DirPaddingFile::FILE);
       if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
     }