mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 15:05:31 +08:00
reload note cache if transaction rollback is detected
This commit is contained in:
parent
197537b159
commit
4311834d75
1 changed files with 8 additions and 2 deletions
|
@ -238,13 +238,19 @@ function transactional(func) {
|
||||||
const ret = dbConnection.transaction(func).deferred();
|
const ret = dbConnection.transaction(func).deferred();
|
||||||
|
|
||||||
if (!dbConnection.inTransaction) { // i.e. transaction was really committed (and not just savepoint released)
|
if (!dbConnection.inTransaction) { // i.e. transaction was really committed (and not just savepoint released)
|
||||||
require('./ws.js').sendTransactionEntityChangesToAllClients();
|
require('./ws').sendTransactionEntityChangesToAllClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
catch (e) {
|
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;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue