зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
6d72631810
Коммит
057785b6d5
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<NotNull<nsCOMPtr<nsIFile>>, nsresult> BodyGetCacheDir(nsIFile& aBaseDir,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<FileUsageType, nsresult> 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<FileUsageType, nsresult> 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>)));
|
||||
|
|
|
@ -526,16 +526,14 @@ Result<nsCOMPtr<mozIStorageConnection>, 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<bool, nsresult> 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<ExistsAsFileResult::DoesNotExist>));
|
||||
// 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<ExistsAsFileResult::DoesNotExist>));
|
||||
|
||||
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!");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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<Ok, nsresult> 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<false>));
|
||||
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<false>));
|
||||
|
||||
if (moved) {
|
||||
RemoveQuotaForOrigin(fullOriginMetadata.mPersistenceType,
|
||||
|
@ -9255,8 +9252,7 @@ void ResetOrClearOp::DeleteFiles(QuotaManager& aQuotaManager) {
|
|||
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!");
|
||||
|
@ -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!");
|
||||
|
|
|
@ -173,9 +173,8 @@ Result<nsCOMPtr<nsIFile>, nsresult> CloneFileAndAppend(
|
|||
Result<nsIFileKind, nsresult> 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<nsIFileKind, nsresult> 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;
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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<nsIInputStream> 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//***********************************************************
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -260,9 +260,7 @@ DataStorage::Reader::Run() {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -749,11 +749,8 @@ static already_AddRefed<nsIFile> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -633,7 +633,6 @@ with modules["FILES"]:
|
|||
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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче