Bug 1828400 - Stop logging errors if nothing is overwritten. r=dom-storage-reviewers,janv

Differential Revision: https://phabricator.services.mozilla.com/D175609
This commit is contained in:
Jari Jalkanen 2023-05-03 11:48:51 +00:00
Родитель 4f71b39dfb
Коммит 60e176584d
2 изменённых файлов: 30 добавлений и 7 удалений

Просмотреть файл

@ -329,14 +329,23 @@ Result<EntryId, QMResult> FindEntryId(const FileSystemConnection& aConnection,
return entryId;
}
bool IsSame(const FileSystemConnection& aConnection,
const FileSystemEntryMetadata& aHandle,
const FileSystemChildMetadata& aNewHandle, bool aIsFile) {
Result<bool, QMResult> IsSame(const FileSystemConnection& aConnection,
const FileSystemEntryMetadata& aHandle,
const FileSystemChildMetadata& aNewHandle,
bool aIsFile) {
MOZ_ASSERT(!aNewHandle.parentId().IsEmpty());
QM_TRY_UNWRAP(EntryId entryId, FindEntryId(aConnection, aNewHandle, aIsFile),
false);
return entryId == aHandle.entryId();
// Typically aNewHandle does not exist which is not an error
QM_TRY_RETURN(QM_OR_ELSE_LOG_VERBOSE_IF(
// Expression.
FindEntryId(aConnection, aNewHandle, aIsFile)
.map([&aHandle](const EntryId& entryId) {
return entryId == aHandle.entryId();
}),
// Predicate.
IsSpecificError<NS_ERROR_DOM_NOT_FOUND_ERR>,
// Fallback.
ErrToOkFromQMResult<false>));
}
Result<bool, QMResult> IsFile(const FileSystemConnection& aConnection,
@ -1338,7 +1347,9 @@ Result<bool, QMResult> FileSystemDatabaseManagerVersion001::MoveEntry(
// If the rename doesn't change the name or directory, just return success.
// XXX Needs to be added to the spec
if (IsSame(mConnection, aHandle, aNewDesignation, isFile)) {
QM_WARNONLY_TRY_UNWRAP(Maybe<bool> maybeSame,
IsSame(mConnection, aHandle, aNewDesignation, isFile));
if (maybeSame && maybeSame.value()) {
return true;
}

Просмотреть файл

@ -1061,6 +1061,13 @@ bool IsSpecificError(const nsresult aValue) {
return aValue == ErrorValue;
}
#ifdef QM_ERROR_STACKS_ENABLED
template <nsresult ErrorValue>
bool IsSpecificError(const QMResult& aValue) {
return aValue.NSResult() == ErrorValue;
}
#endif
// Helper template function so that QM_TRY fallback functions that are
// converting errors into specific in-band success values can be concisely
// written as ErrToOk<SuccessValueToReturn> (with the return type inferred).
@ -1073,6 +1080,11 @@ auto ErrToOk(const nsresult aValue) -> Result<V, nsresult> {
return V{SuccessValue};
}
template <auto SuccessValue, typename V = decltype(SuccessValue)>
auto ErrToOkFromQMResult(const QMResult& aValue) -> Result<V, QMResult> {
return V{SuccessValue};
}
// Helper template function so that QM_TRY fallback functions that are
// suppressing errors by converting them into (generic) success can be
// concisely written as ErrToDefaultOk<>.