@bobfrankston/mailx 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/packages/mailx-store/db.js +12 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Local-first email client with IMAP sync and standalone native app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/mailx.js",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
"express": "^4.21.0",
|
|
62
62
|
"nodemailer": "^7.0.0",
|
|
63
63
|
"ws": "^8.18.0",
|
|
64
|
-
"jsonc-parser": "^3.3.1"
|
|
65
|
-
"better-sqlite3": "^11.7.0"
|
|
64
|
+
"jsonc-parser": "^3.3.1"
|
|
66
65
|
}
|
|
67
66
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Stores message headers, folder structure, sync state.
|
|
4
4
|
* Message bodies are NOT here -- they live in the MessageStore backend.
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { DatabaseSync } from "node:sqlite";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import * as fs from "node:fs";
|
|
9
9
|
const SCHEMA = `
|
|
@@ -118,9 +118,9 @@ export class MailxDB {
|
|
|
118
118
|
constructor(dbDir) {
|
|
119
119
|
fs.mkdirSync(dbDir, { recursive: true });
|
|
120
120
|
const dbPath = path.join(dbDir, "mailx.db");
|
|
121
|
-
this.db = new
|
|
122
|
-
this.db.
|
|
123
|
-
this.db.
|
|
121
|
+
this.db = new DatabaseSync(dbPath);
|
|
122
|
+
this.db.exec("PRAGMA journal_mode = WAL");
|
|
123
|
+
this.db.exec("PRAGMA foreign_keys = ON");
|
|
124
124
|
this.db.exec(SCHEMA);
|
|
125
125
|
}
|
|
126
126
|
close() {
|
|
@@ -462,7 +462,8 @@ export class MailxDB {
|
|
|
462
462
|
const insert = this.db.prepare("INSERT INTO messages_fts (rowid, subject, from_name, from_address, to_text, cc_text, body_text) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
|
463
463
|
const rows = this.db.prepare("SELECT id, subject, from_name, from_address, to_json, cc_json, preview FROM messages").all();
|
|
464
464
|
let count = 0;
|
|
465
|
-
|
|
465
|
+
this.db.exec("BEGIN");
|
|
466
|
+
try {
|
|
466
467
|
for (const r of rows) {
|
|
467
468
|
const to = JSON.parse(r.to_json || "[]");
|
|
468
469
|
const cc = JSON.parse(r.cc_json || "[]");
|
|
@@ -474,8 +475,12 @@ export class MailxDB {
|
|
|
474
475
|
}
|
|
475
476
|
catch { /* skip duplicates */ }
|
|
476
477
|
}
|
|
477
|
-
|
|
478
|
-
|
|
478
|
+
this.db.exec("COMMIT");
|
|
479
|
+
}
|
|
480
|
+
catch (e) {
|
|
481
|
+
this.db.exec("ROLLBACK");
|
|
482
|
+
throw e;
|
|
483
|
+
}
|
|
479
484
|
return count;
|
|
480
485
|
}
|
|
481
486
|
// ── Sync Actions ──
|