Page MenuHomePhabricator

D11309.diff
No OneTemporary

D11309.diff

diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -19,7 +19,10 @@
ClientDBCommunityStoreOperation,
CommunityStoreOperation,
} from '../ops/community-store-ops.js';
-import type { ClientDBIntegrityThreadHash } from '../ops/integrity-store-ops.js';
+import type {
+ ClientDBIntegrityThreadHash,
+ ClientDBIntegrityStoreOperation,
+} from '../ops/integrity-store-ops.js';
import type {
ClientDBKeyserverInfo,
ClientDBKeyserverStoreOperation,
@@ -60,6 +63,7 @@
+reportStoreOperations?: $ReadOnlyArray<ClientDBReportStoreOperation>,
+keyserverStoreOperations?: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
+communityStoreOperations?: $ReadOnlyArray<ClientDBCommunityStoreOperation>,
+ +integrityStoreOperations?: $ReadOnlyArray<ClientDBIntegrityStoreOperation>,
};
export type ClientDBStore = {
diff --git a/web/shared-worker/worker/process-operations.js b/web/shared-worker/worker/process-operations.js
--- a/web/shared-worker/worker/process-operations.js
+++ b/web/shared-worker/worker/process-operations.js
@@ -1,6 +1,7 @@
// @flow
import type { ClientDBCommunityStoreOperation } from 'lib/ops/community-store-ops.js';
+import type { ClientDBIntegrityStoreOperation } from 'lib/ops/integrity-store-ops.js';
import type { ClientDBKeyserverStoreOperation } from 'lib/ops/keyserver-store-ops.js';
import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
@@ -186,6 +187,37 @@
}
}
+function processIntegrityStoreOperations(
+ sqliteQueryExecutor: SQLiteQueryExecutor,
+ operations: $ReadOnlyArray<ClientDBIntegrityStoreOperation>,
+ module: EmscriptenModule,
+) {
+ for (const operation: ClientDBIntegrityStoreOperation of operations) {
+ try {
+ if (operation.type === 'remove_all_integrity_thread_hashes') {
+ sqliteQueryExecutor.removeAllIntegrityThreadHashes();
+ } else if (operation.type === 'remove_integrity_thread_hashes') {
+ const { ids } = operation.payload;
+ sqliteQueryExecutor.removeIntegrityThreadHashes(ids);
+ } else if (operation.type === 'replace_integrity_thread_hashes') {
+ const { threadHashes } = operation.payload;
+ sqliteQueryExecutor.replaceIntegrityThreadHashes(threadHashes);
+ } else {
+ throw new Error('Unsupported integrity operation');
+ }
+ } catch (e) {
+ throw new Error(
+ `Error while processing ${
+ operation.type
+ } integrity operation: ${getProcessingStoreOpsExceptionMessage(
+ e,
+ module,
+ )}`,
+ );
+ }
+ }
+}
+
function processDBStoreOperations(
sqliteQueryExecutor: SQLiteQueryExecutor,
storeOperations: ClientDBStoreOperations,
@@ -197,6 +229,7 @@
threadStoreOperations,
keyserverStoreOperations,
communityStoreOperations,
+ integrityStoreOperations,
} = storeOperations;
try {
@@ -236,6 +269,13 @@
module,
);
}
+ if (integrityStoreOperations && integrityStoreOperations.length > 0) {
+ processIntegrityStoreOperations(
+ sqliteQueryExecutor,
+ integrityStoreOperations,
+ module,
+ );
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
@@ -258,7 +298,7 @@
users: [],
keyservers: sqliteQueryExecutor.getAllKeyservers(),
communities: sqliteQueryExecutor.getAllCommunities(),
- integrityThreadHashes: [],
+ integrityThreadHashes: sqliteQueryExecutor.getAllIntegrityThreadHashes(),
};
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 8, 4:59 AM (3 m, 32 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2813626
Default Alt Text
D11309.diff (3 KB)

Event Timeline