mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
implemented consistency check for note fulltext based on hashes
This commit is contained in:
parent
58f71c7300
commit
946dae72d9
@ -74,7 +74,10 @@ class Note extends Entity {
|
|||||||
/** @returns {Promise<*>} */
|
/** @returns {Promise<*>} */
|
||||||
async getContent() {
|
async getContent() {
|
||||||
if (this.content === undefined) {
|
if (this.content === undefined) {
|
||||||
this.content = await sql.getValue(`SELECT content FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
const res = await sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||||
|
|
||||||
|
this.content = res.content;
|
||||||
|
this.contentHash = res.contentHash; // used only for note_fulltext consistency check
|
||||||
|
|
||||||
if (this.isProtected) {
|
if (this.isProtected) {
|
||||||
if (this.isContentAvailable) {
|
if (this.isContentAvailable) {
|
||||||
|
@ -5,6 +5,7 @@ const sqlInit = require('./sql_init');
|
|||||||
const log = require('./log');
|
const log = require('./log');
|
||||||
const messagingService = require('./messaging');
|
const messagingService = require('./messaging');
|
||||||
const syncMutexService = require('./sync_mutex');
|
const syncMutexService = require('./sync_mutex');
|
||||||
|
const noteFulltextService = require('./note_fulltext');
|
||||||
const repository = require('./repository');
|
const repository = require('./repository');
|
||||||
const cls = require('./cls');
|
const cls = require('./cls');
|
||||||
const syncTableService = require('./sync_table');
|
const syncTableService = require('./sync_table');
|
||||||
@ -357,6 +358,24 @@ async function findLogicIssues() {
|
|||||||
|
|
||||||
logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
|
logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await findAndFixIssues(`
|
||||||
|
SELECT
|
||||||
|
noteId
|
||||||
|
FROM
|
||||||
|
notes
|
||||||
|
JOIN note_contents USING(noteId)
|
||||||
|
LEFT JOIN note_fulltext USING(noteId)
|
||||||
|
WHERE
|
||||||
|
notes.isDeleted = 0
|
||||||
|
AND (note_fulltext.noteId IS NULL
|
||||||
|
OR note_fulltext.titleHash != notes.hash
|
||||||
|
OR note_fulltext.contentHash != note_contents.hash)`,
|
||||||
|
async ({noteId}) => {
|
||||||
|
noteFulltextService.triggerNoteFulltextUpdate(noteId);
|
||||||
|
|
||||||
|
logFix(`Triggered fulltext update of note ${noteId} since it was out of sync.`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runSyncRowChecks(entityName, key) {
|
async function runSyncRowChecks(entityName, key) {
|
||||||
|
@ -20,8 +20,7 @@ async function updateNoteFulltext(note) {
|
|||||||
content = html2plaintext(content);
|
content = html2plaintext(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
contentHash = note.contentHash;
|
||||||
//contentHash = noteContent.hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// optimistically try to update first ...
|
// optimistically try to update first ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user