[go: nahoru, domu]

Skip to content

Commit

Permalink
fix: extra logging in documents content migration (hcengineering#5868)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
  • Loading branch information
aonnikov committed Jun 20, 2024
1 parent dedff23 commit c88adbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions models/document/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,7 @@ async function migrateTeamspacesMixins (client: MigrationClient): Promise<void>

async function migrateContentField (client: MigrationClient): Promise<void> {
const ctx = new MeasureMetricsContext('migrate_content_field', {})

const storage = client.storageAdapter
if (storage === undefined) {
return
}

const documents = await client.find<Document>(DOMAIN_DOCUMENT, {
_class: document.class.Document,
Expand All @@ -290,17 +286,20 @@ async function migrateContentField (client: MigrationClient): Promise<void> {
try {
const ydoc = await loadCollaborativeDoc(storage, client.workspaceId, document.content, ctx)
if (ydoc === undefined) {
ctx.error('document content not found', { document: document.name })
continue
}

if (!ydoc.share.has('')) {
if (!ydoc.share.has('') || ydoc.share.has('content')) {
continue
}

yDocCopyXmlField(ydoc, '', 'content')

await saveCollaborativeDoc(storage, client.workspaceId, document.content, ydoc, ctx)
} catch {}
} catch (err) {
ctx.error('error document content migration', { error: err, document: document.name })
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/model/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface MigrationClient {
model: ModelDb

migrateState: Map<string, Set<string>>
storageAdapter?: StorageAdapter
storageAdapter: StorageAdapter

workspaceId: WorkspaceId
}
Expand Down

0 comments on commit c88adbc

Please sign in to comment.