Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3544015
D10781.id36566.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10781.id36566.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 11:51 AM (7 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2709435
Default Alt Text
D10781.id36566.diff (3 KB)
Attached To
Mode
D10781: [SQLite] implement processing keyserver store ops on worker
Attached
Detach File
Event Timeline
Log In to Comment