implemented consistency check for note fulltext based on hashes

This commit is contained in:
zadam
2019-03-27 21:27:29 +01:00
parent 58f71c7300
commit 946dae72d9
3 changed files with 24 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ const sqlInit = require('./sql_init');
const log = require('./log');
const messagingService = require('./messaging');
const syncMutexService = require('./sync_mutex');
const noteFulltextService = require('./note_fulltext');
const repository = require('./repository');
const cls = require('./cls');
const syncTableService = require('./sync_table');
@@ -357,6 +358,24 @@ async function findLogicIssues() {
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) {