From b31c4e77db5840d9c460b2760e6d49b77fc9882b Mon Sep 17 00:00:00 2001 From: Jari Jalkanen Date: Thu, 5 Jan 2023 11:51:28 +0000 Subject: [PATCH] Bug 1789585 - Store total file size and if size is constant to usage schema. r=dom-storage-reviewers,janv Depends on D163634 Differential Revision: https://phabricator.services.mozilla.com/D163699 --- dom/fs/parent/GetDirectoryForOrigin.cpp | 2 +- dom/fs/parent/datamodel/SchemaVersion001.cpp | 22 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dom/fs/parent/GetDirectoryForOrigin.cpp b/dom/fs/parent/GetDirectoryForOrigin.cpp index 253d4b4fb1ec..c76a8f4b7541 100644 --- a/dom/fs/parent/GetDirectoryForOrigin.cpp +++ b/dom/fs/parent/GetDirectoryForOrigin.cpp @@ -24,7 +24,7 @@ Result, QMResult> GetDirectoryForOrigin( QM_TRY_UNWRAP(auto directory, QM_TO_RESULT_TRANSFORM(quota::QM_NewLocalFile( aQuotaManager.GetBasePath()))); - QM_TRY(QM_TO_RESULT(directory->Append(u"opfs-storage"_ns))); + QM_TRY(QM_TO_RESULT(directory->Append(u"opfs-storage2"_ns))); QM_TRY_UNWRAP(auto originHash, data::FileSystemHashSource::GenerateHash( diff --git a/dom/fs/parent/datamodel/SchemaVersion001.cpp b/dom/fs/parent/datamodel/SchemaVersion001.cpp index 2390cd94b7d9..435b2a6dd1af 100644 --- a/dom/fs/parent/datamodel/SchemaVersion001.cpp +++ b/dom/fs/parent/datamodel/SchemaVersion001.cpp @@ -58,6 +58,19 @@ nsresult CreateFiles(ResultConnection& aConn) { ";"_ns); } +nsresult CreateUsages(ResultConnection& aConn) { + return aConn->ExecuteSimpleSQL( + "CREATE TABLE IF NOT EXISTS Usages ( " + "handle BLOB PRIMARY KEY, " + "usage INTEGER NOT NULL DEFAULT 0, " + "tracked BOOLEAN NOT NULL DEFAULT 0 CHECK (tracked IN (0, 1)), " + "CONSTRAINT handles_are_files " + "FOREIGN KEY (handle) " + "REFERENCES Files (handle) " + "ON DELETE CASCADE ) " + ";"_ns); +} + class KeepForeignKeysOffUntilScopeExit final { public: explicit KeepForeignKeysOffUntilScopeExit(const ResultConnection& aConn) @@ -122,15 +135,6 @@ nsresult CreateRootEntry(ResultConnection& aConn, const Origin& aOrigin) { return transaction.Commit(); } -nsresult CreateUsages(ResultConnection& aConn) { - return aConn->ExecuteSimpleSQL( - "CREATE TABLE IF NOT EXISTS Usages ( " - "usage INTEGER NOT NULL, " - "aggregated BOOLEAN DEFAULT FALSE " - ") " - ";"_ns); -} - Result CheckIfEmpty(ResultConnection& aConn) { const nsLiteralCString areThereTablesQuery = "SELECT EXISTS ("