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