mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 09:45:52 +01:00
move entity hash to entity_changes table
This commit is contained in:
@@ -70,9 +70,9 @@ class Note extends Entity {
|
||||
/** @returns {*} */
|
||||
getContent(silentNotFoundError = false) {
|
||||
if (this.content === undefined) {
|
||||
const res = sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||
const content = sql.getValue(`SELECT content FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||
|
||||
if (!res) {
|
||||
if (!content) {
|
||||
if (silentNotFoundError) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class Note extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
this.content = res.content;
|
||||
this.content = content;
|
||||
|
||||
if (this.isProtected) {
|
||||
if (this.isContentAvailable) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const sql = require('./sql');
|
||||
const repository = require('repository');
|
||||
const repository = require('./repository');
|
||||
const sourceIdService = require('./source_id');
|
||||
const dateUtils = require('./date_utils');
|
||||
const log = require('./log');
|
||||
const cls = require('./cls');
|
||||
|
||||
@@ -12,7 +11,6 @@ function insertEntityChange(entityName, entityId, hash, sourceId = null, isSynce
|
||||
entityName: entityName,
|
||||
entityId: entityId,
|
||||
hash: hash,
|
||||
utcChangedDate: dateUtils.utcNowDateTime(),
|
||||
sourceId: sourceId || cls.getSourceId() || sourceIdService.getCurrentSourceId(),
|
||||
isSynced: isSynced ? 1 : 0
|
||||
};
|
||||
@@ -31,9 +29,9 @@ function addEntityChange(entityName, entityId, hash, sourceId, isSynced) {
|
||||
}
|
||||
|
||||
function moveEntityChangeToTop(entityName, entityId) {
|
||||
const entityChange = sql.getRow(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [entityName, entityId]);
|
||||
const [hash, isSynced] = sql.getRow(`SELECT * FROM entity_changes WHERE entityName = ? AND entityId = ?`, [entityName, entityId]);
|
||||
|
||||
addEntityChange(entityName, entityId, entityChange.hash, null, entityChange.isSynced);
|
||||
addEntityChange(entityName, entityId, hash, null, isSynced);
|
||||
}
|
||||
|
||||
function addEntityChangesForSector(entityName, entityPrimaryKey, sector) {
|
||||
@@ -81,11 +79,10 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
||||
if (existingRows === 0) {
|
||||
createdCount++;
|
||||
|
||||
sql.insert("sync", {
|
||||
sql.insert("entity_changes", {
|
||||
entityName: entityName,
|
||||
entityId: entityId,
|
||||
sourceId: "SYNC_FILL",
|
||||
utcChangedDate: dateUtils.utcNowDateTime(),
|
||||
isSynced: 1
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ function updateEntity(entity) {
|
||||
|
||||
const isSynced = entityName !== 'options' || entity.isSynced;
|
||||
|
||||
entityChangesService.addEntityChange(entityName, primaryKey, null, isSynced);
|
||||
entityChangesService.addEntityChange(entityName, primaryKey, entity.generateHash(), null, isSynced);
|
||||
|
||||
if (!cls.isEntityEventsDisabled()) {
|
||||
const eventPayload = {
|
||||
|
||||
Reference in New Issue
Block a user