diff --git a/db/migrations/0220__migrate_images_to_attachments.js b/db/migrations/0220__migrate_images_to_attachments.js index 512cb3c2f..1815a5d46 100644 --- a/db/migrations/0220__migrate_images_to_attachments.js +++ b/db/migrations/0220__migrate_images_to_attachments.js @@ -3,8 +3,12 @@ module.exports = () => { const becca = require("../../src/becca/becca"); const cls = require("../../src/services/cls"); const log = require("../../src/services/log"); + const sql = require("../../src/services/sql"); cls.init(() => { + // emergency disabling of image compression since it appears to make problems in migration to 0.61 + sql.execute(`UPDATE options SET value = 'false' WHERE name = 'compressImages'`); + beccaLoader.load(); for (const note of Object.values(becca.notes)) { diff --git a/db/migrations/0227__disable_image_compression.sql b/db/migrations/0227__disable_image_compression.sql new file mode 100644 index 000000000..a5350deff --- /dev/null +++ b/db/migrations/0227__disable_image_compression.sql @@ -0,0 +1,2 @@ +-- emergency disabling of image compression since it appears to make problems in migration to 0.61 +UPDATE options SET value = 'false' WHERE name = 'compressImages'; diff --git a/package.json b/package.json index 748a53693..e7d7796a2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.61.11", + "version": "0.61.13", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/public/app/services/server.js b/src/public/app/services/server.js index 48dece334..b8a1d29fb 100644 --- a/src/public/app/services/server.js +++ b/src/public/app/services/server.js @@ -172,7 +172,7 @@ if (utils.isElectron()) { await reportError(arg.method, arg.url, arg.statusCode, arg.body); } - idToRequestMap[arg.requestId].reject(); + idToRequestMap[arg.requestId].reject(new Error(`Server responded with ${arg.statusCode}`)); } delete idToRequestMap[arg.requestId]; diff --git a/src/services/app_info.js b/src/services/app_info.js index 98bc9d59b..7f5a7818a 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -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"; diff --git a/src/services/build.js b/src/services/build.js index 0b00c7049..bf62de945 100644 --- a/src/services/build.js +++ b/src/services/build.js @@ -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" }; diff --git a/src/services/image.js b/src/services/image.js index de71493f3..111a77771 100644 --- a/src/services/image.js +++ b/src/services/image.js @@ -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}) => { diff --git a/src/services/sync.js b/src/services/sync.js index 031666196..ad59f77be 100644 --- a/src/services/sync.js +++ b/src/services/sync.js @@ -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 };