Merge branch 'stable'

This commit is contained in:
zadam
2023-11-06 22:14:15 +01:00
8 changed files with 30 additions and 10 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 = 226;
const APP_DB_VERSION = 227;
const SYNC_VERSION = 31;
const CLIPPER_PROTOCOL_VERSION = "1.0";

View File

@@ -1 +1 @@
module.exports = { buildDate:"2023-11-03T11:46:53+01:00", buildRevision: "01093d05d7ca1ede0c9af3fe2f5b04969ade816d" };
module.exports = { buildDate:"2023-11-06T00:21:41+01:00", buildRevision: "531e9d4aff47b7e8332420645546d25ab28acf85" };

View File

@@ -148,8 +148,16 @@ function saveImageToAttachment(noteId, uploadBuffer, originalName, shrinkImageSw
title: fileName
});
const noteService = require("../services/notes");
noteService.asyncPostProcessContent(note, note.getContent()); // to mark an unused attachment for deletion
// TODO: this is a quick-fix solution of a recursive bug - this is called from asyncPostProcessContent()
// find some async way to do this - perhaps some global timeout with a Set of noteIds needing one more
// run of asyncPostProcessContent
setTimeout(() => {
sql.transactional(() => {
const note = becca.getNoteOrThrow(noteId);
const noteService = require("../services/notes");
noteService.asyncPostProcessContent(note, note.getContent()); // to mark an unused attachment for deletion
});
}, 5000);
// resizing images asynchronously since JIMP does not support sync operation
processImage(uploadBuffer, originalName, shrinkImageSwitch).then(({buffer, imageFormat}) => {

View File

@@ -292,7 +292,9 @@ async function syncRequest(syncContext, method, requestPath, body) {
return response;
}
function getEntityChangeRow(entityName, entityId) {
function getEntityChangeRow(entityChange) {
const {entityName, entityId} = entityChange;
if (entityName === 'note_reordering') {
return sql.getMap("SELECT branchId, notePosition FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [entityId]);
}
@@ -300,13 +302,14 @@ function getEntityChangeRow(entityName, entityId) {
const primaryKey = entityConstructor.getEntityFromEntityName(entityName).primaryKeyName;
if (!primaryKey) {
throw new Error(`Unknown entity '${entityName}'`);
throw new Error(`Unknown entity for entity change ${JSON.stringify(entityChange)}`);
}
const entityRow = sql.getRow(`SELECT * FROM ${entityName} WHERE ${primaryKey} = ?`, [entityId]);
if (!entityRow) {
throw new Error(`Entity ${entityName} '${entityId}' not found.`);
log.error(`Cannot find entity for entity change ${JSON.stringify(entityChange)}`);
return null;
}
if (entityName === 'blobs' && entityRow.content !== null) {
@@ -332,7 +335,10 @@ function getEntityChangeRecords(entityChanges) {
continue;
}
const entity = getEntityChangeRow(entityChange.entityName, entityChange.entityId);
const entity = getEntityChangeRow(entityChange);
if (!entity) {
continue;
}
const record = { entityChange, entity };