From 2d9491d9fb8cf4a367671faac03f170f458fb5f4 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Wed, 15 Jan 2025 23:01:49 +0700 Subject: [PATCH] fix: ignore invalid blob data json files Signed-off-by: Alexander Onnikov --- server/backup/src/backup.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/backup/src/backup.ts b/server/backup/src/backup.ts index dc2c4d544d7..3b592fa46dc 100644 --- a/server/backup/src/backup.ts +++ b/server/backup/src/backup.ts @@ -2006,7 +2006,15 @@ export async function restore ( }) stream.on('end', () => { const bf = Buffer.concat(chunks as any) - const doc = JSON.parse(bf.toString()) as Doc + let doc: Doc + try { + doc = JSON.parse(bf.toString()) as Doc + } catch (err) { + ctx.warn('failed to parse blob metadata', { name, workspace: workspaceId.name, err }) + next() + return + } + if (doc._class === core.class.Blob || doc._class === 'core:class:BlobData') { const data = migradeBlobData(doc as Blob, changeset.get(doc._id) as string) const d = blobs.get(bname) ?? (data !== '' ? Buffer.from(data, 'base64') : undefined)