Page MenuHomePhabricator

D10781.diff
No OneTemporary

D10781.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
@@ -12,7 +12,10 @@
import type { ClientReportCreationRequest } from './report-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
import type { UserInfos } from './user-types.js';
-import type { ClientDBKeyserverInfo } from '../ops/keyserver-store-ops.js';
+import type {
+ ClientDBKeyserverInfo,
+ ClientDBKeyserverStoreOperation,
+} from '../ops/keyserver-store-ops.js';
import type {
ClientDBMessageStoreOperation,
MessageStoreOperation,
@@ -44,6 +47,7 @@
+threadStoreOperations?: $ReadOnlyArray<ClientDBThreadStoreOperation>,
+messageStoreOperations?: $ReadOnlyArray<ClientDBMessageStoreOperation>,
+reportStoreOperations?: $ReadOnlyArray<ClientDBReportStoreOperation>,
+ +keyserverStoreOperations?: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
};
export type ClientDBStore = {
diff --git a/web/database/worker/process-operations.js b/web/database/worker/process-operations.js
--- a/web/database/worker/process-operations.js
+++ b/web/database/worker/process-operations.js
@@ -1,5 +1,6 @@
// @flow
+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';
import type {
@@ -122,13 +123,48 @@
}
}
+function processKeyserverStoreOperations(
+ sqliteQueryExecutor: SQLiteQueryExecutor,
+ operations: $ReadOnlyArray<ClientDBKeyserverStoreOperation>,
+ module: EmscriptenModule,
+) {
+ for (const operation: ClientDBKeyserverStoreOperation of operations) {
+ try {
+ if (operation.type === 'remove_all_keyservers') {
+ sqliteQueryExecutor.removeAllKeyservers();
+ } else if (operation.type === 'remove_keyservers') {
+ const { ids } = operation.payload;
+ sqliteQueryExecutor.removeKeyservers(ids);
+ } else if (operation.type === 'replace_keyserver') {
+ const { id, keyserverInfo } = operation.payload;
+ sqliteQueryExecutor.replaceKeyserver({ id, keyserverInfo });
+ } else {
+ throw new Error('Unsupported keyserver operation');
+ }
+ } catch (e) {
+ throw new Error(
+ `Error while processing ${
+ operation.type
+ } keyserver operation: ${getProcessingStoreOpsExceptionMessage(
+ e,
+ module,
+ )}`,
+ );
+ }
+ }
+}
+
function processDBStoreOperations(
sqliteQueryExecutor: SQLiteQueryExecutor,
storeOperations: ClientDBStoreOperations,
module: EmscriptenModule,
) {
- const { draftStoreOperations, reportStoreOperations, threadStoreOperations } =
- storeOperations;
+ const {
+ draftStoreOperations,
+ reportStoreOperations,
+ threadStoreOperations,
+ keyserverStoreOperations,
+ } = storeOperations;
try {
sqliteQueryExecutor.beginTransaction();
@@ -153,6 +189,13 @@
module,
);
}
+ if (keyserverStoreOperations && keyserverStoreOperations.length > 0) {
+ processKeyserverStoreOperations(
+ sqliteQueryExecutor,
+ keyserverStoreOperations,
+ module,
+ );
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
@@ -173,7 +216,7 @@
messageStoreThreads: [],
reports: sqliteQueryExecutor.getAllReports(),
users: [],
- keyservers: [],
+ keyservers: sqliteQueryExecutor.getAllKeyservers(),
};
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 11:12 PM (11 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2709435
Default Alt Text
D10781.diff (3 KB)

Event Timeline