mnemosyne-core 2.1.5 → 2.1.6

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/dist/index.js CHANGED
@@ -4598,8 +4598,9 @@ var Store = class extends EventEmitter {
4598
4598
  vals.push(this.now());
4599
4599
  sets.push("version = version + 1");
4600
4600
  vals.push(id);
4601
+ const sql = `UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`;
4601
4602
  try {
4602
- this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
4603
+ this.stmt(sql).run(...vals);
4603
4604
  } catch (err) {
4604
4605
  if (err.message?.includes("malformed") || err.message?.includes("corrupt")) {
4605
4606
  throw new Error(`Database appears corrupted. Run "mnemosyne doctor --data-dir ./data" or delete the data directory and run "mnemosyne init" again.`);
@@ -5629,7 +5630,7 @@ CREATE TRIGGER IF NOT EXISTS trig_search_atoms_insert AFTER INSERT ON atoms BEGI
5629
5630
  END;
5630
5631
 
5631
5632
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_update AFTER UPDATE ON atoms BEGIN
5632
- UPDATE search_atoms SET title = new.title, summary = COALESCE(new.summary, '') WHERE rowid = new.rowid;
5633
+ INSERT OR REPLACE INTO search_atoms(rowid, title, summary) VALUES (new.rowid, new.title, COALESCE(new.summary, ''));
5633
5634
  END;
5634
5635
 
5635
5636
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_delete AFTER DELETE ON atoms BEGIN
@@ -7426,6 +7427,10 @@ function getDb() {
7426
7427
  db.pragma("journal_mode = WAL");
7427
7428
  db.pragma("foreign_keys = ON");
7428
7429
  db.pragma("synchronous = NORMAL");
7430
+ try {
7431
+ db.pragma("wal_checkpoint(TRUNCATE)");
7432
+ } catch {
7433
+ }
7429
7434
  try {
7430
7435
  const { getLoadablePath } = require("sqlite-vec");
7431
7436
  db.loadExtension(getLoadablePath());