From 057785b6d597b6fc0d948c85386374f47a1519f3 Mon Sep 17 00:00:00 2001 From: Jan Rio Krause Date: Tue, 5 Apr 2022 15:17:03 +0000 Subject: [PATCH] Bug 1519200 - Remove `NS_ERROR_FILE_TARGET_DOES_NOT_EXIST` in favor of `NS_ERROR_FILE_NOT_FOUND`. r=xpcom-reviewers,nika,dom-storage-reviewers,jstutte Differential Revision: https://phabricator.services.mozilla.com/D77575 --- .../tests/unit/test_Chrome_history.js | 2 +- dom/cache/FileUtils.cpp | 3 +- dom/filesystem/FileSystemTaskBase.cpp | 2 +- dom/indexedDB/ActorsParent.cpp | 26 +++++------- dom/localstorage/ActorsParent.cpp | 42 ++++++++----------- dom/quota/ActorsParent.cpp | 41 ++++++++---------- dom/quota/QuotaCommon.cpp | 6 +-- dom/system/IOUtils.cpp | 5 +-- dom/xhr/XMLHttpRequestMainThread.cpp | 2 +- js/xpconnect/src/xpc.msg | 1 - modules/libjar/nsJAR.cpp | 10 ++--- modules/libjar/nsJARChannel.cpp | 6 +-- modules/libjar/nsJARInputStream.cpp | 4 +- modules/libjar/nsZipArchive.cpp | 4 +- modules/libjar/test/unit/test_bug1550815.js | 2 +- modules/libpref/Preferences.cpp | 3 +- netwerk/base/nsIncrementalDownload.cpp | 3 +- netwerk/cache2/CacheFileIOManager.cpp | 3 +- netwerk/protocol/file/nsFileChannel.cpp | 6 +-- security/manager/ssl/DataStorage.cpp | 4 +- startupcache/StartupCache.cpp | 3 +- toolkit/components/places/Database.cpp | 12 ++---- toolkit/content/aboutProfiles.js | 1 - toolkit/modules/JSONFile.jsm | 10 +---- .../extensions/internal/XPIInstall.jsm | 3 -- toolkit/profile/nsToolkitProfileService.cpp | 3 +- toolkit/xre/nsAppRunner.cpp | 3 +- toolkit/xre/nsXREDirProvider.cpp | 5 +-- .../exthandler/nsExternalHelperAppService.cpp | 1 - xpcom/base/ErrorList.py | 1 - xpcom/io/nsIFile.idl | 4 +- xpcom/io/nsLocalFile.h | 2 +- xpcom/io/nsLocalFileUnix.cpp | 2 +- 33 files changed, 84 insertions(+), 141 deletions(-) diff --git a/browser/components/migration/tests/unit/test_Chrome_history.js b/browser/components/migration/tests/unit/test_Chrome_history.js index de0c7d975123f..9959a637d490b 100644 --- a/browser/components/migration/tests/unit/test_Chrome_history.js +++ b/browser/components/migration/tests/unit/test_Chrome_history.js @@ -135,7 +135,7 @@ function removeHistoryFile() { file.remove(false); } catch (ex) { // It is ok if this doesn't exist. - if (ex.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) { + if (ex.result != Cr.NS_ERROR_FILE_NOT_FOUND) { throw ex; } } diff --git a/dom/cache/FileUtils.cpp b/dom/cache/FileUtils.cpp index 476d8a68fec13..4b3387a902283 100644 --- a/dom/cache/FileUtils.cpp +++ b/dom/cache/FileUtils.cpp @@ -66,8 +66,7 @@ nsresult DirectoryPaddingWrite(nsIFile& aBaseDir, const auto kMorgueDirectory = u"morgue"_ns; bool IsFileNotFoundError(const nsresult aRv) { - return aRv == NS_ERROR_FILE_NOT_FOUND || - aRv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return aRv == NS_ERROR_FILE_NOT_FOUND; } Result>, nsresult> BodyGetCacheDir(nsIFile& aBaseDir, diff --git a/dom/filesystem/FileSystemTaskBase.cpp b/dom/filesystem/FileSystemTaskBase.cpp index 8b04e30b4a3d3..f9c0f9c8ef219 100644 --- a/dom/filesystem/FileSystemTaskBase.cpp +++ b/dom/filesystem/FileSystemTaskBase.cpp @@ -44,7 +44,7 @@ nsresult FileSystemErrorFromNsError(const nsresult& aErrorValue) { case NS_ERROR_FILE_DIR_NOT_EMPTY: return NS_ERROR_DOM_FILESYSTEM_NO_MODIFICATION_ALLOWED_ERR; - case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: + case NS_ERROR_FILE_NOT_FOUND: case NS_ERROR_NOT_AVAILABLE: return NS_ERROR_DOM_FILE_NOT_FOUND_ERR; diff --git a/dom/indexedDB/ActorsParent.cpp b/dom/indexedDB/ActorsParent.cpp index af677ab21a5c2..7475392d518e0 100644 --- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -5718,8 +5718,7 @@ SerializeStructuredCloneFiles(PBackgroundParent* aBackgroundActor, } bool IsFileNotFoundError(const nsresult aRv) { - return aRv == NS_ERROR_FILE_NOT_FOUND || - aRv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return aRv == NS_ERROR_FILE_NOT_FOUND; } enum struct Idempotency { Yes, No }; @@ -5739,8 +5738,8 @@ nsresult DeleteFile(nsIFile& aFile, QuotaManager* const aQuotaManager, // Callers which pass Idempotency::Yes call this function without checking if // the file already exists (idempotent usage). QM_OR_ELSE_WARN_IF is not used - // here since we just want to log NS_ERROR_FILE_NOT_FOUND and - // NS_ERROR_FILE_TARGET_DOES_NOT_EXIST results and not spam the reports. + // here since we just want to log NS_ERROR_FILE_NOT_FOUND results and not spam + // the reports. // Theoretically, there should be no QM_OR_ELSE_(WARN|LOG_VERBOSE)_IF when a // caller passes Idempotency::No, but it's simpler when the predicate just // always returns false in that case. @@ -12381,10 +12380,10 @@ Result DatabaseFileManager::GetUsage( } // Usually we only use QM_OR_ELSE_LOG_VERBOSE(_IF) with Remove and - // NS_ERROR_FILE_NOT_FOUND/NS_ERROR_FILE_TARGET_DOES_NOT_EXIST - // check, but the file was found by a directory traversal and ToInteger - // on the name succeeded, so it should be our file and if the file - // disappears, the use of QM_OR_ELSE_WARN_IF is ok here. + // NS_ERROR_FILE_NOT_FOUND check, but the file was found by a directory + // traversal and ToInteger on the name succeeded, so it should be our + // file and if the file disappears, the use of QM_OR_ELSE_WARN_IF is ok + // here. QM_TRY_INSPECT(const auto& thisUsage, QM_OR_ELSE_WARN_IF( // Expression. @@ -12394,8 +12393,7 @@ Result DatabaseFileManager::GetUsage( }), // Predicate. ([](const nsresult rv) { - return rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST || - rv == NS_ERROR_FILE_NOT_FOUND; + return rv == NS_ERROR_FILE_NOT_FOUND; }), // Fallback. If the file does no longer exist, treat // it as 0-sized. @@ -12822,17 +12820,15 @@ nsresult QuotaClient::GetUsageForOriginInternal( databaseFilename + kSQLiteWALSuffix)); // QM_OR_ELSE_WARN_IF is not used here since we just want to log - // NS_ERROR_FILE_NOT_FOUND/NS_ERROR_FILE_TARGET_DOES_NOT_EXIST - // result and not spam the reports (the -wal file doesn't have to - // exist). + // NS_ERROR_FILE_NOT_FOUND result and not spam the reports (the -wal + // file doesn't have to exist). QM_TRY_INSPECT(const int64_t& walFileSize, QM_OR_ELSE_LOG_VERBOSE_IF( // Expression. MOZ_TO_RESULT_INVOKE_MEMBER(walFile, GetFileSize), // Predicate. ([](const nsresult rv) { - return rv == NS_ERROR_FILE_NOT_FOUND || - rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return rv == NS_ERROR_FILE_NOT_FOUND; }), // Fallback. (ErrToOk<0, int64_t>))); diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp index d9ca5e6393f6b..356588823a838 100644 --- a/dom/localstorage/ActorsParent.cpp +++ b/dom/localstorage/ActorsParent.cpp @@ -526,16 +526,14 @@ Result, nsresult> CreateStorageConnection( // to corrupted state, which is ignored here). // Usually we only use QM_OR_ELSE_LOG_VERBOSE(_IF) with Remove and - // NS_ERROR_FILE_NOT_FOUND/NS_ERROR_FILE_TARGET_DOES_NOT_EXIST - // check, but we're already in the rare case of corruption here, - // so the use of QM_OR_ELSE_WARN_IF is ok here. + // NS_ERROR_FILE_NOT_FOUND check, but we're already in the rare case + // of corruption here, so the use of QM_OR_ELSE_WARN_IF is ok here. QM_TRY(QM_OR_ELSE_WARN_IF( // Expression. MOZ_TO_RESULT(aUsageFile.Remove(false)), // Predicate. ([](const nsresult rv) { - return rv == NS_ERROR_FILE_NOT_FOUND || - rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return rv == NS_ERROR_FILE_NOT_FOUND; }), // Fallback. ErrToDefaultOk<>)); @@ -1001,23 +999,20 @@ Result ExistsAsFile(nsIFile& aFile) { // This is an optimization to check both properties in one OS case, rather // than calling Exists first, and then IsDirectory. IsDirectory also checks // if the path exists. QM_OR_ELSE_WARN_IF is not used here since we just want - // to log NS_ERROR_FILE_NOT_FOUND/NS_ERROR_FILE_TARGET_DOES_NOT_EXIST result - // and not spam the reports. - QM_TRY_INSPECT(const auto& res, - QM_OR_ELSE_LOG_VERBOSE_IF( - // Expression. - MOZ_TO_RESULT_INVOKE_MEMBER(aFile, IsDirectory) - .map([](const bool isDirectory) { - return isDirectory ? ExistsAsFileResult::IsDirectory - : ExistsAsFileResult::IsFile; - }), - // Predicate. - ([](const nsresult rv) { - return rv == NS_ERROR_FILE_NOT_FOUND || - rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; - }), - // Fallback. - ErrToOk)); + // to log NS_ERROR_FILE_NOT_FOUND result and not spam the reports. + QM_TRY_INSPECT( + const auto& res, + QM_OR_ELSE_LOG_VERBOSE_IF( + // Expression. + MOZ_TO_RESULT_INVOKE_MEMBER(aFile, IsDirectory) + .map([](const bool isDirectory) { + return isDirectory ? ExistsAsFileResult::IsDirectory + : ExistsAsFileResult::IsFile; + }), + // Predicate. + ([](const nsresult rv) { return rv == NS_ERROR_FILE_NOT_FOUND; }), + // Fallback. + ErrToOk)); QM_TRY(OkIf(res != ExistsAsFileResult::IsDirectory), Err(NS_ERROR_FAILURE)); @@ -4146,8 +4141,7 @@ nsresult Connection::EnsureStorageConnection() { } 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!"); } }); diff --git a/dom/quota/ActorsParent.cpp b/dom/quota/ActorsParent.cpp index 18aaea268076b..9a3ecc9c086ce 100644 --- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -7178,8 +7178,7 @@ void QuotaManager::DeleteFilesForOrigin(PersistenceType aPersistenceType, GetDirectoryForOrigin(aPersistenceType, aOrigin), QM_VOID); nsresult 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!"); @@ -7245,23 +7244,21 @@ Result QuotaManager::ArchiveOrigins( fullOriginMetadata.mOrigin)); // The origin could have been removed, for example due to corruption. - QM_TRY_INSPECT(const auto& moved, - QM_OR_ELSE_WARN_IF( - // Expression. - MOZ_TO_RESULT(directory->MoveTo( - fullOriginMetadata.mPersistenceType == - PERSISTENCE_TYPE_DEFAULT - ? defaultStorageArchiveDir - : temporaryStorageArchiveDir, - u""_ns)) - .map([](Ok) { return true; }), - // Predicate. - ([](const nsresult rv) { - return rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST || - rv == NS_ERROR_FILE_NOT_FOUND; - }), - // Fallback. - ErrToOk)); + QM_TRY_INSPECT( + const auto& moved, + QM_OR_ELSE_WARN_IF( + // Expression. + MOZ_TO_RESULT( + directory->MoveTo(fullOriginMetadata.mPersistenceType == + PERSISTENCE_TYPE_DEFAULT + ? defaultStorageArchiveDir + : temporaryStorageArchiveDir, + u""_ns)) + .map([](Ok) { return true; }), + // Predicate. + ([](const nsresult rv) { return rv == NS_ERROR_FILE_NOT_FOUND; }), + // Fallback. + ErrToOk)); if (moved) { RemoveQuotaForOrigin(fullOriginMetadata.mPersistenceType, @@ -9255,8 +9252,7 @@ void ResetOrClearOp::DeleteFiles(QuotaManager& aQuotaManager) { nsCOMPtr 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!"); @@ -9274,8 +9270,7 @@ void ResetOrClearOp::DeleteStorageFile(QuotaManager& aQuotaManager) { QM_VOID); const nsresult 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!"); diff --git a/dom/quota/QuotaCommon.cpp b/dom/quota/QuotaCommon.cpp index 35bde8257aaf6..cac34c2e39bd4 100644 --- a/dom/quota/QuotaCommon.cpp +++ b/dom/quota/QuotaCommon.cpp @@ -173,9 +173,8 @@ Result, nsresult> CloneFileAndAppend( Result GetDirEntryKind(nsIFile& aFile) { // Callers call this function without checking if the directory already // exists (idempotent usage). QM_OR_ELSE_WARN_IF is not used here since we - // just want to log NS_ERROR_FILE_NOT_FOUND, - // NS_ERROR_FILE_TARGET_DOES_NOT_EXIST and NS_ERROR_FILE_FS_CORRUPTED results - // and not spam the reports. + // just want to log NS_ERROR_FILE_NOT_FOUND and NS_ERROR_FILE_FS_CORRUPTED + // results and not spam the reports. QM_TRY_RETURN(QM_OR_ELSE_LOG_VERBOSE_IF( MOZ_TO_RESULT_INVOKE_MEMBER(aFile, IsDirectory) .map([](const bool isDirectory) { @@ -184,7 +183,6 @@ Result GetDirEntryKind(nsIFile& aFile) { }), ([](const nsresult rv) { return rv == NS_ERROR_FILE_NOT_FOUND || - 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; diff --git a/dom/system/IOUtils.cpp b/dom/system/IOUtils.cpp index ad38cc9a00e70..3ea654b9630ef 100644 --- a/dom/system/IOUtils.cpp +++ b/dom/system/IOUtils.cpp @@ -93,8 +93,7 @@ namespace mozilla::dom { * @see nsLocalFileUnix.cpp */ static bool IsFileNotFound(nsresult aResult) { - return aResult == NS_ERROR_FILE_NOT_FOUND || - aResult == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return aResult == NS_ERROR_FILE_NOT_FOUND; } /** * Like |IsFileNotFound|, but checks for known results that suggest a file @@ -174,8 +173,6 @@ static void RejectJSPromise(Promise* aPromise, const IOUtils::IOError& aError) { switch (aError.Code()) { case NS_ERROR_FILE_UNRESOLVABLE_SYMLINK: [[fallthrough]]; // to NS_ERROR_FILE_INVALID_PATH - case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: - [[fallthrough]]; // to NS_ERROR_FILE_INVALID_PATH case NS_ERROR_FILE_NOT_FOUND: [[fallthrough]]; // to NS_ERROR_FILE_INVALID_PATH case NS_ERROR_FILE_INVALID_PATH: diff --git a/dom/xhr/XMLHttpRequestMainThread.cpp b/dom/xhr/XMLHttpRequestMainThread.cpp index 413ae1b23adf9..b1175048493aa 100644 --- a/dom/xhr/XMLHttpRequestMainThread.cpp +++ b/dom/xhr/XMLHttpRequestMainThread.cpp @@ -3968,7 +3968,7 @@ nsresult ArrayBufferBuilder::MapToFileInPackage(const nsCString& aFile, } nsZipItem* zipItem = zip->GetItem(aFile.get()); if (!zipItem) { - return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return NS_ERROR_FILE_NOT_FOUND; } // If file was added to the package as stored(uncompressed), map to the diff --git a/js/xpconnect/src/xpc.msg b/js/xpconnect/src/xpc.msg index 0c59109f2fb08..f7c28803485f8 100644 --- a/js/xpconnect/src/xpc.msg +++ b/js/xpconnect/src/xpc.msg @@ -101,7 +101,6 @@ XPC_MSG_DEF(NS_ERROR_FILE_UNRESOLVABLE_SYMLINK , "File error: Unresolvable XPC_MSG_DEF(NS_ERROR_FILE_EXECUTION_FAILED , "File error: Execution failed") XPC_MSG_DEF(NS_ERROR_FILE_UNKNOWN_TYPE , "File error: Unknown type") XPC_MSG_DEF(NS_ERROR_FILE_DESTINATION_NOT_DIR , "File error: Destination not dir") -XPC_MSG_DEF(NS_ERROR_FILE_TARGET_DOES_NOT_EXIST , "File error: Target does not exist") XPC_MSG_DEF(NS_ERROR_FILE_COPY_OR_MOVE_FAILED , "File error: Copy or move failed") XPC_MSG_DEF(NS_ERROR_FILE_ALREADY_EXISTS , "File error: Already exists") XPC_MSG_DEF(NS_ERROR_FILE_INVALID_PATH , "File error: Invalid path") diff --git a/modules/libjar/nsJAR.cpp b/modules/libjar/nsJAR.cpp index d3032980160a4..4dbef243a761b 100644 --- a/modules/libjar/nsJAR.cpp +++ b/modules/libjar/nsJAR.cpp @@ -206,7 +206,7 @@ nsJAR::Extract(const nsACString& aEntryName, nsIFile* outFile) { LOG(("Extract[%p] %s", this, PromiseFlatCString(aEntryName).get())); nsZipItem* item = mZip->GetItem(PromiseFlatCString(aEntryName).get()); - NS_ENSURE_TRUE(item, NS_ERROR_FILE_TARGET_DOES_NOT_EXIST); + NS_ENSURE_TRUE(item, NS_ERROR_FILE_NOT_FOUND); // Remove existing file or directory so we set permissions correctly. // If it's a directory that already exists and contains files, throw @@ -246,7 +246,7 @@ nsJAR::GetEntry(const nsACString& aEntryName, nsIZipEntry** result) { return NS_ERROR_FAILURE; } nsZipItem* zipItem = mZip->GetItem(PromiseFlatCString(aEntryName).get()); - NS_ENSURE_TRUE(zipItem, NS_ERROR_FILE_TARGET_DOES_NOT_EXIST); + NS_ENSURE_TRUE(zipItem, NS_ERROR_FILE_NOT_FOUND); nsJARItem* jarItem = new nsJARItem(zipItem); @@ -310,7 +310,7 @@ nsJAR::GetInputStreamWithSpec(const nsACString& aJarDirSpec, if (*entry.get()) { // First check if item exists in jar item = mZip->GetItem(entry.get()); - if (!item) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + if (!item) return NS_ERROR_FILE_NOT_FOUND; } nsJARInputStream* jis = new nsJARInputStream(); // addref now so we can call InitFile/InitDirectory() @@ -375,7 +375,7 @@ nsresult nsJAR::LoadEntry(const nsACString& aFilename, nsCString& aBuf) { nsresult rv; nsCOMPtr manifestStream; rv = GetInputStream(aFilename, getter_AddRefs(manifestStream)); - if (NS_FAILED(rv)) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + if (NS_FAILED(rv)) return NS_ERROR_FILE_NOT_FOUND; //-- Read the manifest file into memory char* buf; @@ -438,7 +438,7 @@ nsJAREnumerator::HasMore(bool* aResult) { if (!mName) { NS_ASSERTION(mFind, "nsJAREnumerator: Missing zipFind."); nsresult rv = mFind->FindNext(&mName, &mNameLen); - if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) { + if (rv == NS_ERROR_FILE_NOT_FOUND) { *aResult = false; // No more matches available return NS_OK; } diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 84265a69374a5..9cfd931a5afe6 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -116,9 +116,6 @@ nsresult nsJARInputThunk::Init() { rv = mJarReader->GetInputStream(mJarEntry, getter_AddRefs(mJarStream)); } if (NS_FAILED(rv)) { - // convert to the proper result if the entry wasn't found - // so that error pages work - if (rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) rv = NS_ERROR_FILE_NOT_FOUND; return rv; } @@ -281,8 +278,7 @@ nsresult nsJARChannel::CreateJarInput(nsIZipReaderCache* jarCache, new nsJARInputThunk(reader, mJarURI, mJarEntry, jarCache != nullptr); rv = input->Init(); if (NS_FAILED(rv)) { - if (rv == NS_ERROR_FILE_NOT_FOUND || - rv == NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) { + if (rv == NS_ERROR_FILE_NOT_FOUND) { CheckForBrokenChromeURL(mLoadInfo, mOriginalURI); } return rv; diff --git a/modules/libjar/nsJARInputStream.cpp b/modules/libjar/nsJARInputStream.cpp index c21ec47182cd1..5a5a26c4ba0b6 100644 --- a/modules/libjar/nsJARInputStream.cpp +++ b/modules/libjar/nsJARInputStream.cpp @@ -127,7 +127,7 @@ nsresult nsJARInputStream::InitDirectory(nsJAR* aJar, mArray.AppendElement(nsCString(name, nameLen)); } - if (rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && NS_FAILED(rv)) { + if (rv != NS_ERROR_FILE_NOT_FOUND && NS_FAILED(rv)) { return NS_ERROR_FAILURE; // no error translation } @@ -317,7 +317,7 @@ nsresult nsJARInputStream::ReadDirectory(char* aBuffer, uint32_t aCount, const char* entryName = mArray[mArrPos].get(); uint32_t entryNameLen = mArray[mArrPos].Length(); nsZipItem* ze = mJar->mZip->GetItem(entryName); - NS_ENSURE_TRUE(ze, NS_ERROR_FILE_TARGET_DOES_NOT_EXIST); + NS_ENSURE_TRUE(ze, NS_ERROR_FILE_NOT_FOUND); // Last Modified Time PRExplodedTime tm; diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index f87453b498cd9..c2a23516e1cc0 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -387,7 +387,7 @@ nsresult nsZipArchive::Test(const char* aEntryName) { if (aEntryName) // only test specified item { currItem = GetItem(aEntryName); - if (!currItem) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + if (!currItem) return NS_ERROR_FILE_NOT_FOUND; //-- don't test (synthetic) directory items if (currItem->IsDirectory()) return NS_OK; return ExtractFile(currItem, 0, 0); @@ -582,7 +582,7 @@ nsresult nsZipFind::FindNext(const char** aResult, uint16_t* aNameLen) { } MMAP_FAULT_HANDLER_CATCH(NS_ERROR_FAILURE) LOG(("ZipHandle::FindNext[%p] not found %s", this, mPattern)); - return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST; + return NS_ERROR_FILE_NOT_FOUND; } //*********************************************************** diff --git a/modules/libjar/test/unit/test_bug1550815.js b/modules/libjar/test/unit/test_bug1550815.js index 01e332de4f5c1..cb6264de7a828 100644 --- a/modules/libjar/test/unit/test_bug1550815.js +++ b/modules/libjar/test/unit/test_bug1550815.js @@ -24,7 +24,7 @@ function run_test() { zipReader.test("modules/libjar/test/Makefile.in"); Assert.ok(false, "Should not reach here."); } catch (e) { - Assert.equal(e.result, Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST); + Assert.equal(e.result, Cr.NS_ERROR_FILE_NOT_FOUND); } zipReader.close(); diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index fa88d4b4ec18a..1c1a8648f0c76 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -4272,8 +4272,7 @@ static nsresult pref_LoadPrefsInDir(nsIFile* aDir, 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; diff --git a/netwerk/base/nsIncrementalDownload.cpp b/netwerk/base/nsIncrementalDownload.cpp index 4dd7c8903f3ff..2c3120ef96ac0 100644 --- a/netwerk/base/nsIncrementalDownload.cpp +++ b/netwerk/base/nsIncrementalDownload.cpp @@ -287,8 +287,7 @@ nsresult nsIncrementalDownload::ProcessTimeout() { 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; } diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index 06ca89e67157a..8f910942825a5 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -2144,8 +2144,7 @@ nsresult CacheFileIOManager::DoomFileInternal( 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; diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 8c9262d2b6680..47caa94c88e6b 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -292,9 +292,6 @@ nsresult nsFileChannel::MakeFileInputStream(nsIFile* 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 (rv == NS_ERROR_FILE_NOT_FOUND) { CheckForBrokenChromeURL(mLoadInfo, OriginalURI()); } @@ -455,8 +452,7 @@ nsresult nsFileChannel::FixupContentLength(bool async) { 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; diff --git a/security/manager/ssl/DataStorage.cpp b/security/manager/ssl/DataStorage.cpp index 781d4c99527c8..f75048af4c0b7 100644 --- a/security/manager/ssl/DataStorage.cpp +++ b/security/manager/ssl/DataStorage.cpp @@ -260,9 +260,7 @@ DataStorage::Reader::Run() { nsCOMPtr 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; } diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index cd527a3debd18..250de03b6e950 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -652,8 +652,7 @@ void StartupCache::InvalidateCache(bool memoryOnly) { 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; } diff --git a/toolkit/components/places/Database.cpp b/toolkit/components/places/Database.cpp index 25d1829a6a842..0da6db97c5737 100644 --- a/toolkit/components/places/Database.cpp +++ b/toolkit/components/places/Database.cpp @@ -774,8 +774,7 @@ nsresult Database::BackupAndReplaceDatabaseFile( 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; } @@ -823,8 +822,7 @@ nsresult Database::BackupAndReplaceDatabaseFile( // 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; } @@ -882,8 +880,7 @@ nsresult Database::TryToCloneTablesFromCorruptDatabase( 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; } @@ -1054,8 +1051,7 @@ nsresult Database::SetupDatabaseConnection( 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); diff --git a/toolkit/content/aboutProfiles.js b/toolkit/content/aboutProfiles.js index 36b730f0688ea..311e3b003ab71 100644 --- a/toolkit/content/aboutProfiles.js +++ b/toolkit/content/aboutProfiles.js @@ -73,7 +73,6 @@ function rebuildProfileList() { lock.unlock(); } catch (e) { if ( - e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && e.result != Cr.NS_ERROR_FILE_NOT_DIRECTORY && e.result != Cr.NS_ERROR_FILE_NOT_FOUND ) { diff --git a/toolkit/modules/JSONFile.jsm b/toolkit/modules/JSONFile.jsm index 7ea81987b0892..5d4e5c0f9cede 100644 --- a/toolkit/modules/JSONFile.jsm +++ b/toolkit/modules/JSONFile.jsm @@ -372,10 +372,7 @@ JSONFile.prototype = { let backupFile = new FileUtils.File(this._options.backupFile); backupFile.copyTo(null, basename); } catch (e) { - if ( - e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && - e.result != Cr.NS_ERROR_FILE_NOT_FOUND - ) { + if (e.result != Cr.NS_ERROR_FILE_NOT_FOUND) { Cu.reportError(e); } } @@ -401,10 +398,7 @@ JSONFile.prototype = { inputStream.close(); } } catch (e3) { - if ( - e3.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && - e3.result != Cr.NS_ERROR_FILE_NOT_FOUND - ) { + if (e3.result != Cr.NS_ERROR_FILE_NOT_FOUND) { Cu.reportError(e3); } } diff --git a/toolkit/mozapps/extensions/internal/XPIInstall.jsm b/toolkit/mozapps/extensions/internal/XPIInstall.jsm index 3e9cbbdd7b46c..b9b61bc3200e1 100644 --- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm +++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm @@ -1020,9 +1020,6 @@ function recursiveRemove(aFile) { // If the file has already gone away then don't worry about it, this can // happen on OSX where the resource fork is automatically moved with the // data fork for the file. See bug 733436. - if (e.result == Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) { - return; - } if (e.result == Cr.NS_ERROR_FILE_NOT_FOUND) { return; } diff --git a/toolkit/profile/nsToolkitProfileService.cpp b/toolkit/profile/nsToolkitProfileService.cpp index c16355c887f12..04e9a73f37931 100644 --- a/toolkit/profile/nsToolkitProfileService.cpp +++ b/toolkit/profile/nsToolkitProfileService.cpp @@ -2055,8 +2055,7 @@ nsToolkitProfileService::Flush() { 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; } } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index b0d3fd3f6ff61..1749c100eb16b 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -3661,8 +3661,7 @@ static bool RemoveComponentRegistries(nsIFile* aProfileDir, file->SetNativeLeafName("startupCache"_ns); 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, diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index f0e449ce82d72..5536f4423f4af 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -749,11 +749,8 @@ static already_AddRefed CreateProcessSandboxTempDir( 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; } } diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 6e9fb1aff06f2..b32f7bf0536f0 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -2214,7 +2214,6 @@ void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv, break; case NS_ERROR_FILE_NOT_FOUND: - case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST: case NS_ERROR_FILE_UNRECOGNIZED_PATH: // Helper app not found, let's verify this happened on launch if (type == kLaunchError) { diff --git a/xpcom/base/ErrorList.py b/xpcom/base/ErrorList.py index 13935c0842d99..52bdafa665e5f 100755 --- a/xpcom/base/ErrorList.py +++ b/xpcom/base/ErrorList.py @@ -633,7 +633,6 @@ def SUCCESS(code): errors["NS_ERROR_FILE_EXECUTION_FAILED"] = FAILURE(3) errors["NS_ERROR_FILE_UNKNOWN_TYPE"] = FAILURE(4) errors["NS_ERROR_FILE_DESTINATION_NOT_DIR"] = FAILURE(5) - errors["NS_ERROR_FILE_TARGET_DOES_NOT_EXIST"] = FAILURE(6) errors["NS_ERROR_FILE_COPY_OR_MOVE_FAILED"] = FAILURE(7) errors["NS_ERROR_FILE_ALREADY_EXISTS"] = FAILURE(8) errors["NS_ERROR_FILE_INVALID_PATH"] = FAILURE(9) diff --git a/xpcom/io/nsIFile.idl b/xpcom/io/nsIFile.idl index 4192f943bef2b..e938965236b43 100644 --- a/xpcom/io/nsIFile.idl +++ b/xpcom/io/nsIFile.idl @@ -121,7 +121,7 @@ interface nsIFile : nsISupports * This will copy this file to the specified newParentDir. * If a newName is specified, the file will be renamed. * If 'this' is not created we will return an error - * (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST). + * (NS_ERROR_FILE_NOT_FOUND). * * copyTo may fail if the file already exists in the destination * directory. @@ -163,7 +163,7 @@ interface nsIFile : nsISupports * A method to move this file or directory to newParentDir. * If a newName is specified, the file or directory will be renamed. * If 'this' is not created we will return an error - * (NS_ERROR_FILE_TARGET_DOES_NOT_EXIST). + * (NS_ERROR_FILE_NOT_FOUND). * If 'this' is a file, and the destination file already exists, moveTo * will replace the old file. * This object is updated to refer to the new file. diff --git a/xpcom/io/nsLocalFile.h b/xpcom/io/nsLocalFile.h index ff050229a5e35..779b2e6c95807 100644 --- a/xpcom/io/nsLocalFile.h +++ b/xpcom/io/nsLocalFile.h @@ -67,7 +67,7 @@ inline nsresult nsresultForErrno(int aErr) { 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 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index b609a0b890272..1558f0afb6cc3 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1130,7 +1130,7 @@ nsLocalFile::Remove(bool 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