Bug 1690326 - Follow-up fix for the ERROR_FILE_CORRUPT to NS_ERROR_FILE_FS_CORRUPTED mapping; r=jstutte
authorJan Varga <jvarga@mozilla.com>
Wed, 28 Apr 2021 07:33:54 +0000
changeset 577789 a98b826be2d8f8c19cf1baaeaa7b40ce0daa9fc0
parent 577788 f12ca19c644ab00833ef1ba683caf8e120f4a9bb
child 577790 ecbf5c7d3a62e39485d0c7e6a21b3a78f4cb68de
push id142070
push userjvarga@mozilla.com
push dateWed, 28 Apr 2021 07:36:31 +0000
treeherderautoland@1ea87880589f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjstutte
bugs1690326
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 1690326 - Follow-up fix for the ERROR_FILE_CORRUPT to NS_ERROR_FILE_FS_CORRUPTED mapping; r=jstutte The code which depends on the old generic NS_ERROR_MODULE_WIN32 mapping needs to be updated too. Depends on D113505 Differential Revision: https://phabricator.services.mozilla.com/D113518
dom/cache/FileUtils.cpp
dom/cache/QuotaClient.cpp
dom/quota/QuotaCommon.cpp
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -381,29 +381,25 @@ nsresult BodyDeleteOrphanedFiles(const Q
 
               return false;
             };
             CACHE_TRY(
                 ToResult(BodyTraverseFiles(aQuotaInfo, *subdir,
                                            removeOrphanedFiles,
                                            /* aCanRemoveFiles */ true,
                                            /* aTrackQuota */ true))
-#ifdef WIN32
                     .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
-                      // We treat ERROR_FILE_CORRUPT as if the directory did
-                      // not exist at all.
-                      if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_WIN32 &&
-                          NS_ERROR_GET_CODE(rv) == ERROR_FILE_CORRUPT) {
+                      // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
+                      // directory did not exist at all.
+                      if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
                         return Ok{};
                       }
 
                       return Err(rv);
-                    })
-#endif
-            );
+                    }));
             break;
           }
 
           case nsIFileKind::ExistsAsFile: {
             // If a file got in here somehow, try to remove it and move on
             DebugOnly<nsresult> result =
                 RemoveNsIFile(aQuotaInfo, *subdir, /* aTrackQuota */ false);
             MOZ_ASSERT(NS_SUCCEEDED(result));
--- a/dom/cache/QuotaClient.cpp
+++ b/dom/cache/QuotaClient.cpp
@@ -100,29 +100,25 @@ Result<UsageInfo, nsresult> GetBodyUsage
           // tests. Note that file usage hasn't been exposed to users yet.
           usageInfo += DatabaseUsageType(Some(fileSize));
 
           return false;
         };
         CACHE_TRY(ToResult(BodyTraverseFiles(QuotaInfo{}, *bodyDir, getUsage,
                                              /* aCanRemoveFiles */ true,
                                              /* aTrackQuota */ false))
-#ifdef WIN32
                       .orElse([](const nsresult rv) -> Result<Ok, nsresult> {
-                        // We treat ERROR_FILE_CORRUPT as if the directory did
-                        // not exist at all.
-                        if (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_WIN32 &&
-                            NS_ERROR_GET_CODE(rv) == ERROR_FILE_CORRUPT) {
+                        // We treat NS_ERROR_FILE_FS_CORRUPTED as if the
+                        // directory did not exist at all.
+                        if (rv == NS_ERROR_FILE_FS_CORRUPTED) {
                           return Ok{};
                         }
 
                         return Err(rv);
-                      })
-#endif
-        );
+                      }));
         return usageInfo;
       }));
 }
 
 Result<int64_t, nsresult> GetPaddingSizeFromDB(
     nsIFile& aDir, nsIFile& aDBFile, const OriginMetadata& aOriginMetadata) {
   QuotaInfo quotaInfo;
   static_cast<OriginMetadata&>(quotaInfo) = aOriginMetadata;
--- a/dom/quota/QuotaCommon.cpp
+++ b/dom/quota/QuotaCommon.cpp
@@ -166,24 +166,20 @@ Result<nsCOMPtr<nsIFile>, nsresult> Clon
 Result<nsIFileKind, nsresult> GetDirEntryKind(nsIFile& aFile) {
   QM_TRY_RETURN(QM_OR_ELSE_WARN(
       MOZ_TO_RESULT_INVOKE(aFile, IsDirectory).map([](const bool isDirectory) {
         return isDirectory ? nsIFileKind::ExistsAsDirectory
                            : nsIFileKind::ExistsAsFile;
       }),
       ([](const nsresult rv) -> Result<nsIFileKind, nsresult> {
         if (rv == NS_ERROR_FILE_NOT_FOUND ||
-            rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST
-#ifdef WIN32
-            // We treat ERROR_FILE_CORRUPT as if the file did not exist at
-            // all.
-            || (NS_ERROR_GET_MODULE(rv) == NS_ERROR_MODULE_WIN32 &&
-                NS_ERROR_GET_CODE(rv) == ERROR_FILE_CORRUPT)
-#endif
-        ) {
+            rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ||
+            // We treat NS_ERROR_FILE_FS_CORRUPTED as if the file did not exist
+            // at all.
+            rv == NS_ERROR_FILE_FS_CORRUPTED) {
           return nsIFileKind::DoesNotExist;
         }
 
         return Err(rv);
       })));
 }
 
 Result<nsCOMPtr<mozIStorageStatement>, nsresult> CreateStatement(