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.mjs CHANGED
@@ -4568,8 +4568,9 @@ var Store = class extends EventEmitter {
4568
4568
  vals.push(this.now());
4569
4569
  sets.push("version = version + 1");
4570
4570
  vals.push(id);
4571
+ const sql = `UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`;
4571
4572
  try {
4572
- this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
4573
+ this.stmt(sql).run(...vals);
4573
4574
  } catch (err) {
4574
4575
  if (err.message?.includes("malformed") || err.message?.includes("corrupt")) {
4575
4576
  throw new Error(`Database appears corrupted. Run "mnemosyne doctor --data-dir ./data" or delete the data directory and run "mnemosyne init" again.`);
@@ -5599,7 +5600,7 @@ CREATE TRIGGER IF NOT EXISTS trig_search_atoms_insert AFTER INSERT ON atoms BEGI
5599
5600
  END;
5600
5601
 
5601
5602
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_update AFTER UPDATE ON atoms BEGIN
5602
- UPDATE search_atoms SET title = new.title, summary = COALESCE(new.summary, '') WHERE rowid = new.rowid;
5603
+ INSERT OR REPLACE INTO search_atoms(rowid, title, summary) VALUES (new.rowid, new.title, COALESCE(new.summary, ''));
5603
5604
  END;
5604
5605
 
5605
5606
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_delete AFTER DELETE ON atoms BEGIN
@@ -7396,6 +7397,10 @@ function getDb() {
7396
7397
  db.pragma("journal_mode = WAL");
7397
7398
  db.pragma("foreign_keys = ON");
7398
7399
  db.pragma("synchronous = NORMAL");
7400
+ try {
7401
+ db.pragma("wal_checkpoint(TRUNCATE)");
7402
+ } catch {
7403
+ }
7399
7404
  try {
7400
7405
  const { getLoadablePath } = __require("sqlite-vec");
7401
7406
  db.loadExtension(getLoadablePath());