fix: another attempt to migrate empty document fields (#7004)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov
2024-10-21 15:02:22 +07:00
committed by GitHub
parent 996978ef26
commit f06a6e2bc8
10 changed files with 65 additions and 56 deletions
+2 -2
View File
@@ -1270,7 +1270,7 @@ async function updateYDoc (
doc: RelatedDocument
): Promise<void> {
try {
const ydoc = await loadCollaborativeDoc(storage, workspaceId, _id, ctx)
const ydoc = await loadCollaborativeDoc(ctx, storage, workspaceId, _id)
if (ydoc === undefined) {
ctx.error('document content not found', { document: contentDoc._id })
return
@@ -1284,7 +1284,7 @@ async function updateYDoc (
})
if (updatedYDoc !== undefined) {
await saveCollaborativeDoc(storage, workspaceId, _id, updatedYDoc, ctx)
await saveCollaborativeDoc(ctx, storage, workspaceId, _id, updatedYDoc)
}
} catch {
// do nothing, the collaborative doc does not sem to exist yet
+3 -3
View File
@@ -199,7 +199,7 @@ async function processMigrateMarkupFor (
if (blob === undefined) {
try {
const ydoc = markupToYDoc(value, attribute.name)
await saveCollaborativeDoc(storageAdapter, workspaceId, collaborativeDoc, ydoc, ctx)
await saveCollaborativeDoc(ctx, storageAdapter, workspaceId, collaborativeDoc, ydoc)
} catch (err) {
console.error('failed to process document', doc._class, doc._id, err)
}
@@ -298,7 +298,7 @@ export async function restoreLostMarkup (
console.log(doc._class, doc._id, attr.name, markup)
if (command === 'restore') {
const ydoc = markupToYDoc(markup, attr.name)
await saveCollaborativeDoc(storageAdapter, workspaceId, value, ydoc, ctx)
await saveCollaborativeDoc(ctx, storageAdapter, workspaceId, value, ydoc)
}
restored = true
break
@@ -329,7 +329,7 @@ export async function restoreLostMarkup (
console.log(doc._class, doc._id, attr.name, markup)
if (command === 'restore') {
const ydoc = markupToYDoc(markup, attr.name)
await saveCollaborativeDoc(storageAdapter, workspaceId, value, ydoc, ctx)
await saveCollaborativeDoc(ctx, storageAdapter, workspaceId, value, ydoc)
}
}
}