Skip to content

Build your personal knowledge base with Trilium Notes

reload note cache if transaction rollback is detected

zadam4311834d7569
diff --git a/src/services/sql.js b/src/services/sql.js
index 3768624b42..0210e29f4e 100644
--- a/src/services/sql.js
+++ b/src/services/sql.js
@@ -238,13 +238,19 @@ function transactional(func) {
const ret = dbConnection.transaction(func).deferred();
if (!dbConnection.inTransaction) { // i.e. transaction was really committed (and not just savepoint released)
- require('./ws.js').sendTransactionEntityChangesToAllClients();
+ require('./ws').sendTransactionEntityChangesToAllClients();
}
return ret;
}
catch (e) {
- cls.clearEntityChanges();
+ const entityChanges = cls.getAndClearEntityChanges();
+
+ if (entityChanges.length > 0) {
+ log.info("Transaction rollback dirtied the note cache, forcing reload.");
+
+ require('./note_cache/note_cache_loader').load();
+ }
throw e;
}