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.
@@ -6169,8 +6169,9 @@ var Store = class extends EventEmitter {
6169
6169
  vals.push(this.now());
6170
6170
  sets.push("version = version + 1");
6171
6171
  vals.push(id);
6172
+ const sql = `UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`;
6172
6173
  try {
6173
- this.stmt(`UPDATE atoms SET ${sets.join(", ")} WHERE id = ?`).run(...vals);
6174
+ this.stmt(sql).run(...vals);
6174
6175
  } catch (err) {
6175
6176
  if (err.message?.includes("malformed") || err.message?.includes("corrupt")) {
6176
6177
  throw new Error(`Database appears corrupted. Run "mnemosyne doctor --data-dir ./data" or delete the data directory and run "mnemosyne init" again.`);
@@ -7063,7 +7064,7 @@ CREATE TRIGGER IF NOT EXISTS trig_search_atoms_insert AFTER INSERT ON atoms BEGI
7063
7064
  END;
7064
7065
 
7065
7066
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_update AFTER UPDATE ON atoms BEGIN
7066
- UPDATE search_atoms SET title = new.title, summary = COALESCE(new.summary, '') WHERE rowid = new.rowid;
7067
+ INSERT OR REPLACE INTO search_atoms(rowid, title, summary) VALUES (new.rowid, new.title, COALESCE(new.summary, ''));
7067
7068
  END;
7068
7069
 
7069
7070
  CREATE TRIGGER IF NOT EXISTS trig_search_atoms_delete AFTER DELETE ON atoms BEGIN
@@ -7113,6 +7114,10 @@ function getDb() {
7113
7114
  db.pragma("journal_mode = WAL");
7114
7115
  db.pragma("foreign_keys = ON");
7115
7116
  db.pragma("synchronous = NORMAL");
7117
+ try {
7118
+ db.pragma("wal_checkpoint(TRUNCATE)");
7119
+ } catch {
7120
+ }
7116
7121
  try {
7117
7122
  const { getLoadablePath } = __require("sqlite-vec");
7118
7123
  db.loadExtension(getLoadablePath());