forked from mirrors/gecko-dev
Bug 1841726 - Clean up OPFS datamodel files. r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D182755
This commit is contained in:
parent
611fed8ace
commit
f0a515b51b
4 changed files with 22 additions and 14 deletions
|
|
@ -167,8 +167,8 @@ FileSystemDataManager::FileSystemDataManager(
|
|||
mIOTarget(std::move(aIOTarget)),
|
||||
mIOTaskQueue(std::move(aIOTaskQueue)),
|
||||
mRegCount(0),
|
||||
mState(State::Initial),
|
||||
mVersion(0) {}
|
||||
mVersion(0),
|
||||
mState(State::Initial) {}
|
||||
|
||||
FileSystemDataManager::~FileSystemDataManager() {
|
||||
NS_ASSERT_OWNINGTHREAD(FileSystemDataManager);
|
||||
|
|
@ -403,14 +403,14 @@ Result<bool, QMResult> FileSystemDataManager::IsLocked(
|
|||
|
||||
Result<FileId, QMResult> FileSystemDataManager::LockExclusive(
|
||||
const EntryId& aEntryId) {
|
||||
QM_TRY_INSPECT(const FileId& fileId,
|
||||
mDatabaseManager->EnsureFileId(aEntryId));
|
||||
|
||||
QM_TRY_UNWRAP(const bool isLocked, IsLocked(aEntryId));
|
||||
if (isLocked) {
|
||||
return Err(QMResult(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR));
|
||||
}
|
||||
|
||||
QM_TRY_INSPECT(const FileId& fileId,
|
||||
mDatabaseManager->EnsureFileId(aEntryId));
|
||||
|
||||
// If the file has been removed, we should get a file not found error.
|
||||
// Otherwise, if usage tracking cannot be started because file size is not
|
||||
// known and attempts to read it are failing, lock is denied to freeze the
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ class FileSystemDataManager
|
|||
MozPromiseHolder<BoolPromise> mOpenPromiseHolder;
|
||||
MozPromiseHolder<BoolPromise> mClosePromiseHolder;
|
||||
uint32_t mRegCount;
|
||||
State mState;
|
||||
DatabaseVersion mVersion;
|
||||
State mState;
|
||||
};
|
||||
|
||||
} // namespace fs::data
|
||||
|
|
|
|||
|
|
@ -587,14 +587,22 @@ Result<FileId, QMResult> FileSystemDatabaseManagerVersion002::EnsureFileId(
|
|||
return Err(QMResult(NS_ERROR_DOM_NOT_FOUND_ERR));
|
||||
}
|
||||
|
||||
auto mainFileRes = GetFileId(aEntryId);
|
||||
if (mainFileRes.isOk()) {
|
||||
return mainFileRes.unwrap();
|
||||
}
|
||||
QM_TRY_UNWRAP(Maybe<FileId> maybeMainFileId,
|
||||
QM_OR_ELSE_LOG_VERBOSE_IF(
|
||||
// Expression.
|
||||
GetFileId(aEntryId).map([](auto mainFileId) {
|
||||
return Some(std::move(mainFileId));
|
||||
}),
|
||||
// Predicate.
|
||||
IsSpecificError<NS_ERROR_DOM_NOT_FOUND_ERR>,
|
||||
// Fallback.
|
||||
([](const auto&) -> Result<Maybe<FileId>, QMResult> {
|
||||
return Maybe<FileId>{};
|
||||
})));
|
||||
|
||||
QM_TRY(
|
||||
OkIf(ToNSResult(mainFileRes.inspectErr()) == NS_ERROR_DOM_NOT_FOUND_ERR),
|
||||
Err(mainFileRes.unwrapErr()));
|
||||
if (maybeMainFileId) {
|
||||
return *maybeMainFileId;
|
||||
}
|
||||
|
||||
QM_TRY_UNWRAP(auto transaction, StartedTransaction::Create(mConnection));
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsIFileProtocolHandler.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsILocalFileWin.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsTHashMap.h"
|
||||
#include "nsXPCOM.h"
|
||||
|
|
@ -285,6 +284,7 @@ Result<nsCOMPtr<nsIFile>, QMResult> FileSystemFileManager::CreateFileFrom(
|
|||
const FileId& aDestinationFileId, const FileId& aSourceFileId) {
|
||||
MOZ_ASSERT(!aDestinationFileId.IsEmpty());
|
||||
MOZ_ASSERT(!aSourceFileId.IsEmpty());
|
||||
|
||||
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> original, GetFile(aSourceFileId));
|
||||
|
||||
QM_TRY_UNWRAP(nsCOMPtr<nsIFile> destination,
|
||||
|
|
|
|||
Loading…
Reference in a new issue