fix recent notes (db & sync version increase)

This commit is contained in:
zadam
2019-05-21 21:47:28 +02:00
parent ced02b42b5
commit 29828f8e8f
16 changed files with 196 additions and 176 deletions

View File

@@ -4,8 +4,8 @@ const build = require('./build');
const packageJson = require('../../package');
const {TRILIUM_DATA_DIR} = require('./data_dir');
const APP_DB_VERSION = 135;
const SYNC_VERSION = 8;
const APP_DB_VERSION = 136;
const SYNC_VERSION = 9;
module.exports = {
appVersion: packageJson.version,

View File

@@ -396,7 +396,7 @@ async function findSyncRowsIssues() {
await runSyncRowChecks("note_contents", "noteId");
await runSyncRowChecks("note_revisions", "noteRevisionId");
await runSyncRowChecks("branches", "branchId");
await runSyncRowChecks("recent_notes", "branchId");
await runSyncRowChecks("recent_notes", "noteId");
await runSyncRowChecks("attributes", "attributeId");
await runSyncRowChecks("api_tokens", "apiTokenId");
await runSyncRowChecks("options", "name");

View File

@@ -246,7 +246,7 @@ const primaryKeys = {
"note_contents": "noteId",
"branches": "branchId",
"note_revisions": "noteRevisionId",
"recent_notes": "branchId",
"recent_notes": "noteId",
"api_tokens": "apiTokenId",
"options": "name",
"attributes": "attributeId",

View File

@@ -28,8 +28,8 @@ async function addOptionsSync(name, sourceId) {
await addEntitySync("options", name, sourceId);
}
async function addRecentNoteSync(branchId, sourceId) {
await addEntitySync("recent_notes", branchId, sourceId);
async function addRecentNoteSync(noteId, sourceId) {
await addEntitySync("recent_notes", noteId, sourceId);
}
async function addLinkSync(linkId, sourceId) {
@@ -91,7 +91,7 @@ async function fillAllSyncRows() {
await fillSyncRows("note_contents", "noteId");
await fillSyncRows("branches", "branchId");
await fillSyncRows("note_revisions", "noteRevisionId");
await fillSyncRows("recent_notes", "branchId");
await fillSyncRows("recent_notes", "noteId");
await fillSyncRows("attributes", "attributeId");
await fillSyncRows("api_tokens", "apiTokenId");
await fillSyncRows("links", "linkId");

View File

@@ -148,13 +148,13 @@ async function updateOptions(entity, sourceId) {
}
async function updateRecentNotes(entity, sourceId) {
const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE branchId = ?", [entity.branchId]);
const orig = await sql.getRowOrNull("SELECT * FROM recent_notes WHERE noteId = ?", [entity.noteId]);
if (orig === null || orig.utcDateCreated < entity.utcDateCreated) {
await sql.transactional(async () => {
await sql.replace('recent_notes', entity);
await syncTableService.addRecentNoteSync(entity.branchId, sourceId);
await syncTableService.addRecentNoteSync(entity.noteId, sourceId);
});
}
}