erasing note revisions

This commit is contained in:
zadam
2019-11-09 15:21:14 +01:00
parent 7cd75cebfc
commit 9b24ae0600
10 changed files with 213 additions and 92 deletions

View File

@@ -4,7 +4,7 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 152;
const APP_DB_VERSION = 153;
const SYNC_VERSION = 11;
const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@@ -470,11 +470,20 @@ async function eraseDeletedNotes() {
utcDateModified = '${utcNowDateTime}'
WHERE noteId IN (???)`, noteIdsToErase);
// deleting first contents since the WHERE relies on isErased = 0
await sql.executeMany(`
UPDATE note_revisions
UPDATE note_revision_contents
SET content = NULL,
utcDateModified = '${utcNowDateTime}'
WHERE noteId IN (???)`, noteIdsToErase);
WHERE noteRevisionId IN
(SELECT noteRevisionId FROM note_revisions WHERE isErased = 0 AND noteId IN ((???)))`, noteIdsToErase);
await sql.executeMany(`
UPDATE note_revisions
SET isErased = 1,
title = NULL,
utcDateModified = '${utcNowDateTime}'
WHERE isErased = 0 AND noteId IN (???)`, noteIdsToErase);
}
async function duplicateNote(noteId, parentNoteId) {

View File

@@ -18,6 +18,9 @@ async function updateEntity(sync, entity, sourceId) {
else if (entityName === 'note_revisions') {
await updateNoteRevision(entity, sourceId);
}
else if (entityName === 'note_revision_contents') {
await updateNoteRevisionContent(entity, sourceId);
}
else if (entityName === 'note_reordering') {
await updateNoteReordering(sync.entityId, entity, sourceId);
}