Bug 1519200 - Make nsLocalFile consistent with for unix and windows to return NS_ERROR_FILE_NOT_FOUND draft
authorChris Fronk <fronkc1@gmail.com>
Sat, 30 May 2020 02:48:11 +0000
changeset 2927595 e84b136d920fa71d65d8fda5d63c22a3571ac2cc
parent 2927161 a58cc68b0c51645d34cbc7f8f8a30edae77ab396
child 2927596 8d124a0db606f16d8b53b84ab48b48febcf8b888
push id546251
push userreviewbot
push dateSat, 30 May 2020 02:48:34 +0000
treeherdertry@8d124a0db606 [default view] [failures only]
bugs1519200
milestone78.0a1
Bug 1519200 - Make nsLocalFile consistent with for unix and windows to return NS_ERROR_FILE_NOT_FOUND Summary: Also cleans up existing checks that were checking both file not found and target does not exist. Test Plan: Reviewers: Subscribers: Bug #: 1519200 Differential Diff: PHID-DIFF-idndezil3cnmjl4dgrjb
dom/cache/FileUtils.cpp
dom/cache/QuotaClient.cpp
dom/indexedDB/ActorsParent.cpp
dom/localstorage/ActorsParent.cpp
dom/quota/ActorsParent.cpp
modules/libpref/Preferences.cpp
netwerk/base/nsIncrementalDownload.cpp
netwerk/cache2/CacheFileIOManager.cpp
netwerk/protocol/file/nsFileChannel.cpp
security/manager/ssl/DataStorage.cpp
startupcache/StartupCache.cpp
toolkit/components/places/Database.cpp
toolkit/profile/nsToolkitProfileService.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsXREDirProvider.cpp
xpcom/io/nsLocalFile.h
xpcom/io/nsLocalFileUnix.cpp
--- a/dom/cache/FileUtils.cpp
+++ b/dom/cache/FileUtils.cpp
@@ -660,18 +660,17 @@ bool MarkerFileExists(const QuotaInfo& a
 
 // static
 nsresult RemoveNsIFileRecursively(const QuotaInfo& aQuotaInfo, nsIFile* aFile,
                                   const bool aTrackQuota) {
   MOZ_DIAGNOSTIC_ASSERT(aFile);
 
   bool isDirectory = false;
   nsresult rv = aFile->IsDirectory(&isDirectory);
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     return NS_OK;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!isDirectory) {
     return RemoveNsIFile(aQuotaInfo, aFile, aTrackQuota);
@@ -710,28 +709,26 @@ nsresult RemoveNsIFileRecursively(const 
 nsresult RemoveNsIFile(const QuotaInfo& aQuotaInfo, nsIFile* aFile,
                        const bool aTrackQuota) {
   MOZ_DIAGNOSTIC_ASSERT(aFile);
 
   nsresult rv;
   int64_t fileSize = 0;
   if (aTrackQuota) {
     rv = aFile->GetFileSize(&fileSize);
-    if (rv == NS_ERROR_FILE_NOT_FOUND ||
-        rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+    if (rv == NS_ERROR_FILE_NOT_FOUND) {
       return NS_OK;
     }
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
 
   rv = aFile->Remove(/* recursive */ false);
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     MOZ_ASSERT(!aTrackQuota);
     return NS_OK;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (aTrackQuota && fileSize > 0) {
@@ -854,18 +851,17 @@ nsresult LockedUpdateDirectoryPaddingFil
   MOZ_DIAGNOSTIC_ASSERT(aDecreaseSize >= 0);
 
   int64_t currentPaddingSize = 0;
   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) {
+    if (rv != NS_ERROR_FILE_NOT_FOUND) {
       // 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;
       }
     }
 
@@ -1034,18 +1030,17 @@ nsresult LockedDirectoryPaddingDeleteFil
   } else {
     rv = file->Append(NS_LITERAL_STRING(PADDING_FILE_NAME));
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = file->Remove(/* recursive */ false);
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     return NS_OK;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return rv;
 }
--- a/dom/cache/QuotaClient.cpp
+++ b/dom/cache/QuotaClient.cpp
@@ -122,18 +122,17 @@ static nsresult LockedGetPaddingSizeFrom
   // OriginInfo) are only being created so it doesn't make sense to tunnel
   // quota information to TelemetryVFS to get corresponding QuotaObject instance
   // for the SQLite file).
   MOZ_DIAGNOSTIC_ASSERT(quotaInfo.mDirectoryLockId == -1);
 
   nsCOMPtr<mozIStorageConnection> conn;
   nsresult rv = mozilla::dom::cache::OpenDBConnection(quotaInfo, aDir,
                                                       getter_AddRefs(conn));
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     // Return NS_OK with size = 0 if both the db and padding file don't exist.
     // There is no other way to get the overall padding size of an origin.
     return NS_OK;
   }
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -9344,33 +9344,29 @@ nsresult DeleteFile(nsIFile& aFile, Quot
                     const Idempotency aIdempotent) {
   MOZ_ASSERT(!NS_IsMainThread());
   MOZ_ASSERT(!IsOnBackgroundThread());
 
   nsresult rv;
   int64_t fileSize;
   if (aQuotaManager) {
     rv = aFile.GetFileSize(&fileSize);
-    if (aIdempotent == Idempotency::Yes &&
-        (rv == NS_ERROR_FILE_NOT_FOUND ||
-         rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
+    if (aIdempotent == Idempotency::Yes && rv == NS_ERROR_FILE_NOT_FOUND) {
       return NS_OK;
     }
 
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     MOZ_ASSERT(fileSize >= 0);
   }
 
   rv = aFile.Remove(false);
-  if (aIdempotent == Idempotency::Yes &&
-      (rv == NS_ERROR_FILE_NOT_FOUND ||
-       rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
+  if (aIdempotent == Idempotency::Yes && rv == NS_ERROR_FILE_NOT_FOUND) {
     return NS_OK;
   }
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (aQuotaManager && fileSize > 0) {
@@ -9422,18 +9418,17 @@ nsresult DeleteFilesNoQuota(nsIFile* aDi
   }
 
   rv = file->Append(aFilename);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = file->Remove(true);
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     return NS_OK;
   }
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   return NS_OK;
@@ -17364,18 +17359,17 @@ nsresult QuotaClient::GetUsageForOriginI
       MOZ_ASSERT(fileSize >= 0);
 
       aUsageInfo->AppendToDatabaseUsage(Some(uint64_t(fileSize)));
 
       rv = walFile->GetFileSize(&fileSize);
       if (NS_SUCCEEDED(rv)) {
         MOZ_ASSERT(fileSize >= 0);
         aUsageInfo->AppendToDatabaseUsage(Some(uint64_t(fileSize)));
-      } else if (NS_WARN_IF(rv != NS_ERROR_FILE_NOT_FOUND &&
-                            rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) {
+      } else if (NS_WARN_IF(rv != NS_ERROR_FILE_NOT_FOUND)) {
         REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, IDB_GetWalFileSize);
         return rv;
       }
 
       Maybe<uint64_t> usage;
       rv = FileManager::GetUsage(fmDirectory, usage);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, IDB_GetUsage);
--- a/dom/localstorage/ActorsParent.cpp
+++ b/dom/localstorage/ActorsParent.cpp
@@ -1147,18 +1147,17 @@ nsresult UpdateUsageFile(nsIFile* aUsage
                          int64_t aUsage) {
   MOZ_ASSERT(IsOnIOThread() || IsOnConnectionThread());
   MOZ_ASSERT(aUsageFile);
   MOZ_ASSERT(aUsageJournalFile);
   MOZ_ASSERT(aUsage >= 0);
 
   bool isDirectory;
   nsresult rv = aUsageJournalFile->IsDirectory(&isDirectory);
-  if (rv != NS_ERROR_FILE_NOT_FOUND &&
-      rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND) {
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (NS_WARN_IF(isDirectory)) {
       return NS_ERROR_FAILURE;
     }
   } else {
@@ -4327,18 +4326,17 @@ nsresult Connection::EnsureStorageConnec
   bool removedUsageFile;
 
   auto autoRemove = MakeScopeExit([&] {
     if (storageConnection) {
       MOZ_ALWAYS_SUCCEEDS(storageConnection->Close());
     }
 
     nsresult rv = directoryEntry->Remove(false);
-    if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-        rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
+    if (rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
       NS_WARNING("Failed to remove database file!");
     }
   });
 
   rv = CreateStorageConnection(directoryEntry, usageFile, mOrigin,
                                getter_AddRefs(storageConnection),
                                &removedUsageFile);
 
@@ -8763,18 +8761,17 @@ nsresult QuotaClient::InitOrigin(Persist
     REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_GetUsageFile);
     return rv;
   }
 
   bool usageFileExists;
 
   bool isDirectory;
   rv = usageFile->IsDirectory(&isDirectory);
-  if (rv != NS_ERROR_FILE_NOT_FOUND &&
-      rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND) {
     if (NS_WARN_IF(NS_FAILED(rv))) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_IsDirectory);
       return rv;
     }
 
     if (NS_WARN_IF(isDirectory)) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaInternalError, LS_UnexpectedDir);
       return NS_ERROR_FAILURE;
@@ -8788,18 +8785,17 @@ nsresult QuotaClient::InitOrigin(Persist
   nsCOMPtr<nsIFile> usageJournalFile;
   rv = GetUsageJournalFile(directoryPath, getter_AddRefs(usageJournalFile));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_GetUsageForJFile);
     return rv;
   }
 
   rv = usageJournalFile->IsDirectory(&isDirectory);
-  if (rv != NS_ERROR_FILE_NOT_FOUND &&
-      rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND) {
     if (NS_WARN_IF(NS_FAILED(rv))) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_IsDirectory2);
       return rv;
     }
 
     if (NS_WARN_IF(isDirectory)) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaInternalError, LS_UnexpectedDir2);
       return NS_ERROR_FAILURE;
@@ -8831,18 +8827,17 @@ nsresult QuotaClient::InitOrigin(Persist
 
   rv = file->Append(NS_LITERAL_STRING(DATA_FILE_NAME));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_Append2);
     return rv;
   }
 
   rv = file->IsDirectory(&isDirectory);
-  if (rv != NS_ERROR_FILE_NOT_FOUND &&
-      rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND) {
     if (NS_WARN_IF(NS_FAILED(rv))) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_IsDirectory3);
       return rv;
     }
 
     if (NS_WARN_IF(isDirectory)) {
       REPORT_TELEMETRY_INIT_ERR(kQuotaInternalError, LS_UnexpectedDir3);
       return NS_ERROR_FAILURE;
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -7797,18 +7797,17 @@ void QuotaManager::CheckTemporaryStorage
 void QuotaManager::DeleteFilesForOrigin(PersistenceType aPersistenceType,
                                         const nsACString& aOrigin) {
   nsCOMPtr<nsIFile> directory;
   nsresult rv = GetDirectoryForOrigin(aPersistenceType, aOrigin,
                                       getter_AddRefs(directory));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   rv = directory->Remove(true);
-  if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-      rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
     // This should never fail if we've closed all storage connections
     // correctly...
     NS_ERROR("Failed to remove directory!");
   }
 }
 
 void QuotaManager::FinalizeOriginEviction(
     nsTArray<RefPtr<DirectoryLockImpl>>& aLocks) {
@@ -9743,18 +9742,17 @@ void ResetOrClearOp::DeleteFiles(QuotaMa
   auto directoryOrErr = QM_NewLocalFile(aQuotaManager.GetStoragePath());
   if (NS_WARN_IF(directoryOrErr.isErr())) {
     return;
   }
 
   nsCOMPtr<nsIFile> directory = directoryOrErr.unwrap();
 
   rv = directory->Remove(true);
-  if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-      rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
     // This should never fail if we've closed all storage connections
     // correctly...
     MOZ_ASSERT(false, "Failed to remove storage directory!");
   }
 }
 
 void ResetOrClearOp::DeleteStorageFile(QuotaManager& aQuotaManager) {
   AssertIsOnIOThread();
@@ -9768,18 +9766,17 @@ void ResetOrClearOp::DeleteStorageFile(Q
 
   nsresult rv =
       storageFile->Append(aQuotaManager.GetStorageName() + kSQLiteSuffix);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   rv = storageFile->Remove(true);
-  if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-      rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
+  if (rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) {
     // This should never fail if we've closed the storage connection
     // correctly...
     MOZ_ASSERT(false, "Failed to remove storage file!");
   }
 }
 
 nsresult ResetOrClearOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
   AssertIsOnIOThread();
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -4228,18 +4228,17 @@ static nsresult pref_LoadPrefsInDir(nsIF
   nsCOMPtr<nsIDirectoryEnumerator> dirIterator;
 
   // This may fail in some normal cases, such as embedders who do not use a
   // GRE.
   rv = aDir->GetDirectoryEntries(getter_AddRefs(dirIterator));
   if (NS_FAILED(rv)) {
     // If the directory doesn't exist, then we have no reason to complain. We
     // loaded everything (and nothing) successfully.
-    if (rv == NS_ERROR_FILE_NOT_FOUND ||
-        rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+    if (rv == NS_ERROR_FILE_NOT_FOUND) {
       rv = NS_OK;
     }
     return rv;
   }
 
   nsCOMArray<nsIFile> prefFiles(INITIAL_PREF_FILES);
   nsCOMArray<nsIFile> specialFiles(aSpecialFilesCount);
   nsCOMPtr<nsIFile> prefFile;
--- a/netwerk/base/nsIncrementalDownload.cpp
+++ b/netwerk/base/nsIncrementalDownload.cpp
@@ -281,18 +281,17 @@ nsresult nsIncrementalDownload::ProcessT
   mChannel = channel;
   return NS_OK;
 }
 
 // Reads the current file size and validates it.
 nsresult nsIncrementalDownload::ReadCurrentSize() {
   int64_t size;
   nsresult rv = mDest->GetFileSize((int64_t*)&size);
-  if (rv == NS_ERROR_FILE_NOT_FOUND ||
-      rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+  if (rv == NS_ERROR_FILE_NOT_FOUND) {
     mCurrentSize = 0;
     return NS_OK;
   }
   if (NS_FAILED(rv)) return rv;
 
   mCurrentSize = size;
   return NS_OK;
 }
--- a/netwerk/cache2/CacheFileIOManager.cpp
+++ b/netwerk/cache2/CacheFileIOManager.cpp
@@ -2144,18 +2144,17 @@ nsresult CacheFileIOManager::DoomFileInt
     rv = file->GetParent(getter_AddRefs(parentDir));
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoCString leafName;
     rv = file->GetNativeLeafName(leafName);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = aHandle->mFile->MoveToNative(parentDir, leafName);
-    if (NS_ERROR_FILE_NOT_FOUND == rv ||
-        NS_ERROR_FILE_TARGET_DOES_NOT_EXIST == rv) {
+    if (NS_ERROR_FILE_NOT_FOUND == rv) {
       LOG(("  file already removed under our hands"));
       aHandle->mFileExists = false;
       rv = NS_OK;
     } else {
       NS_ENSURE_SUCCESS(rv, rv);
       aHandle->mFile.swap(file);
     }
   }
--- a/netwerk/protocol/file/nsFileChannel.cpp
+++ b/netwerk/protocol/file/nsFileChannel.cpp
@@ -286,19 +286,16 @@ nsresult nsFileChannel::Init() {
 nsresult nsFileChannel::MakeFileInputStream(nsIFile* file,
                                             nsCOMPtr<nsIInputStream>& stream,
                                             nsCString& contentType,
                                             bool async) {
   // we accept that this might result in a disk hit to stat the file
   bool isDir;
   nsresult rv = file->IsDirectory(&isDir);
   if (NS_FAILED(rv)) {
-    // canonicalize error message
-    if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) rv = NS_ERROR_FILE_NOT_FOUND;
-
     if (async && (NS_ERROR_FILE_NOT_FOUND == rv)) {
       // We don't return "Not Found" errors here. Since we could not find
       // the file, it's not a directory anyway.
       isDir = false;
     } else {
       return rv;
     }
   }
@@ -443,18 +440,17 @@ nsresult nsFileChannel::FixupContentLeng
   nsresult rv = GetFile(getter_AddRefs(file));
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   int64_t size;
   rv = file->GetFileSize(&size);
   if (NS_FAILED(rv)) {
-    if (async && (NS_ERROR_FILE_NOT_FOUND == rv ||
-                  NS_ERROR_FILE_TARGET_DOES_NOT_EXIST == rv)) {
+    if (async && NS_ERROR_FILE_NOT_FOUND == rv) {
       size = 0;
     } else {
       return rv;
     }
   }
   mContentLength = size;
 
   return NS_OK;
--- a/security/manager/ssl/DataStorage.cpp
+++ b/security/manager/ssl/DataStorage.cpp
@@ -527,19 +527,17 @@ DataStorage::Reader::Run() {
     rv = mDataStorage->mBackingFile->Clone(getter_AddRefs(file));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   }
   nsCOMPtr<nsIInputStream> fileInputStream;
   rv = NS_NewLocalFileInputStream(getter_AddRefs(fileInputStream), file);
   // If we failed for some reason other than the file doesn't exist, bail.
-  if (NS_WARN_IF(NS_FAILED(rv) &&
-                 rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&  // on Unix
-                 rv != NS_ERROR_FILE_NOT_FOUND)) {             // on Windows
+  if (NS_WARN_IF(NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND)) {
     return rv;
   }
 
   // If there is a file with data in it, read it. If there isn't,
   // we'll essentially fall through to notifying that we're good to go.
   nsCString data;
   if (fileInputStream) {
     // Limit to 2MB of data, but only store sMaxDataEntries entries.
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -618,18 +618,17 @@ void StartupCache::InvalidateCache(bool 
     mCurTableReferenced = false;
   } else {
     mTable.clear();
   }
   mRequestedCount = 0;
   if (!memoryOnly) {
     mCacheData.reset();
     nsresult rv = mFile->Remove(false);
-    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-        rv != NS_ERROR_FILE_NOT_FOUND) {
+    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
       gIgnoreDiskCache = true;
       return;
     }
   }
   gIgnoreDiskCache = false;
   auto result = LoadArchive();
   if (NS_WARN_IF(result.isErr())) {
     gIgnoreDiskCache = true;
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -790,18 +790,17 @@ nsresult Database::BackupAndReplaceDatab
     // Ensure we never create more than one corrupt file.
     nsCOMPtr<nsIFile> corruptFile;
     rv = profDir->Clone(getter_AddRefs(corruptFile));
     NS_ENSURE_SUCCESS(rv, rv);
     nsString corruptFilename = getCorruptFilename(aDbFilename);
     rv = corruptFile->Append(corruptFilename);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = corruptFile->Remove(false);
-    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-        rv != NS_ERROR_FILE_NOT_FOUND) {
+    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
       return rv;
     }
 
     nsCOMPtr<nsIFile> backup;
     Unused << aStorage->BackupDatabaseFile(databaseFile, corruptFilename,
                                            profDir, getter_AddRefs(backup));
   }
 
@@ -839,18 +838,17 @@ nsresult Database::BackupAndReplaceDatab
       rv = mMainConn->SpinningSynchronousClose();
       NS_ENSURE_SUCCESS(rv, rv);
       mMainConn = nullptr;
     }
 
     // Remove the broken database.
     stage = stage_removing;
     rv = databaseFile->Remove(false);
-    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-        rv != NS_ERROR_FILE_NOT_FOUND) {
+    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
       return rv;
     }
 
     // Create a new database file and try to clone tables from the corrupt one.
     bool cloned = false;
     if (aTryToClone &&
         Preferences::GetBool(PREF_DATABASE_CLONEONCORRUPTION, true)) {
       stage = stage_cloning;
@@ -897,18 +895,17 @@ nsresult Database::TryToCloneTablesFromC
 
   nsCOMPtr<nsIFile> recoverFile;
   rv = aDatabaseFile->Clone(getter_AddRefs(recoverFile));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = recoverFile->SetLeafName(getRecoverFilename(filename));
   NS_ENSURE_SUCCESS(rv, rv);
   // Ensure there's no previous recover file.
   rv = recoverFile->Remove(false);
-  if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-      rv != NS_ERROR_FILE_NOT_FOUND) {
+  if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
     return rv;
   }
 
   nsCOMPtr<mozIStorageConnection> conn;
   auto guard = MakeScopeExit([&]() {
     if (conn) {
       Unused << conn->Close();
     }
@@ -1068,18 +1065,17 @@ nsresult Database::SetupDatabaseConnecti
     // The favicons database may be corrupt. Try to replace and reattach it.
     nsCOMPtr<nsIFile> iconsFile;
     rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
                                 getter_AddRefs(iconsFile));
     NS_ENSURE_SUCCESS(rv, rv);
     rv = iconsFile->Append(DATABASE_FAVICONS_FILENAME);
     NS_ENSURE_SUCCESS(rv, rv);
     rv = iconsFile->Remove(false);
-    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-        rv != NS_ERROR_FILE_NOT_FOUND) {
+    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
       return rv;
     }
     rv = EnsureFaviconsDatabaseAttached(aStorage);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Create favicons temp entities.
   rv = mMainConn->ExecuteSimpleSQL(CREATE_ICONS_AFTERINSERT_TRIGGER);
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -1974,18 +1974,17 @@ nsToolkitProfileService::Flush() {
       if (fwrite(data.get(), sizeof(char), length, writeFile) != length) {
         fclose(writeFile);
         return NS_ERROR_UNEXPECTED;
       }
 
       fclose(writeFile);
     } else {
       rv = mInstallDBFile->Remove(false);
-      if (NS_FAILED(rv) && rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST &&
-          rv != NS_ERROR_FILE_NOT_FOUND) {
+      if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
         return rv;
       }
     }
   }
 
   rv = mProfileDB.WriteToFile(mProfileDBFile);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2672,18 +2672,17 @@ static bool RemoveComponentRegistries(ns
   file->AppendNative(NS_LITERAL_CSTRING("XUL" PLATFORM_FASL_SUFFIX));
   file->Remove(false);
 
   file->SetNativeLeafName(NS_LITERAL_CSTRING("XPC" PLATFORM_FASL_SUFFIX));
   file->Remove(false);
 
   file->SetNativeLeafName(NS_LITERAL_CSTRING("startupCache"));
   nsresult rv = file->Remove(true);
-  return NS_SUCCEEDED(rv) || rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ||
-         rv == NS_ERROR_FILE_NOT_FOUND;
+  return NS_SUCCEEDED(rv) || rv == NS_ERROR_FILE_NOT_FOUND;
 }
 
 // When we first initialize the crash reporter we don't have a profile,
 // so we set the minidump path to $TEMP.  Once we have a profile,
 // we set it to $PROFILE/minidumps, creating the directory
 // if needed.
 static void MakeOrSetMinidumpPath(nsIFile* profD) {
   nsCOMPtr<nsIFile> dumpD;
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -814,21 +814,18 @@ static already_AddRefed<nsIFile> CreateP
   }
 
   return sandboxTempDir.forget();
 }
 
 static nsresult DeleteDirIfExists(nsIFile* dir) {
   if (dir) {
     // Don't return an error if the directory doesn't exist.
-    // Windows Remove() returns NS_ERROR_FILE_NOT_FOUND while
-    // OS X returns NS_ERROR_FILE_TARGET_DOES_NOT_EXIST.
     nsresult rv = dir->Remove(/* aRecursive */ true);
-    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND &&
-        rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+    if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND) {
       return rv;
     }
   }
   return NS_OK;
 }
 
 #endif  // defined(MOZ_SANDBOX)
 
--- a/xpcom/io/nsLocalFile.h
+++ b/xpcom/io/nsLocalFile.h
@@ -62,17 +62,17 @@ inline nsresult nsresultForErrno(int aEr
     case EISDIR: /*      Is a directory. */
       return NS_ERROR_FILE_IS_DIRECTORY;
 #endif
     case ENAMETOOLONG:
       return NS_ERROR_FILE_NAME_TOO_LONG;
     case ENOEXEC: /*     Executable file format error. */
       return NS_ERROR_FILE_EXECUTION_FAILED;
     case ENOENT:
-      return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST;
+      return NS_ERROR_FILE_NOT_FOUND;
     case ENOTDIR:
       return NS_ERROR_FILE_DESTINATION_NOT_DIR;
 #ifdef ELOOP
     case ELOOP:
       return NS_ERROR_FILE_UNRESOLVABLE_SYMLINK;
 #endif /* ELOOP */
 #ifdef ENOLINK
     case ENOLINK:
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -1055,17 +1055,17 @@ nsLocalFile::Remove(bool aRecursive) {
       nsCOMPtr<nsIFile> file = do_QueryInterface(item, &rv);
       if (NS_FAILED(rv)) {
         return NS_ERROR_FAILURE;
       }
       rv = file->Remove(aRecursive);
 
 #ifdef ANDROID
       // See bug 580434 - Bionic gives us just deleted files
-      if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) {
+      if (rv == NS_ERROR_FILE_NOT_FOUND) {
         continue;
       }
 #endif
       if (NS_FAILED(rv)) {
         return rv;
       }
     }
   }