mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 00:56:26 +08:00
fix(server): limit rootDoc snapshot size (#12625)
close CLOUD-225 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for reading document blocks without requiring a workspace or root document snapshot. - **Bug Fixes** - Improved handling of large workspace snapshots by skipping them when they exceed 10MB. - **Tests** - Introduced new test cases to cover scenarios where root or workspace snapshots are absent. - Expanded snapshot tests for document block reading. - **Refactor** - Updated several function signatures to make root and workspace snapshot parameters optional for greater flexibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -226,11 +226,14 @@ export class IndexerService {
|
||||
this.logger.debug(`doc ${workspaceId}/${docId} is empty, skip indexing`);
|
||||
return;
|
||||
}
|
||||
const MAX_WORKSPACE_SNAPSHOT_SIZE = 1024 * 1024 * 10; // 10MB
|
||||
const result = await readAllBlocksFromDocSnapshot(
|
||||
workspaceId,
|
||||
workspaceSnapshot.blob,
|
||||
docId,
|
||||
docSnapshot.blob
|
||||
docSnapshot.blob,
|
||||
workspaceSnapshot.blob.length < MAX_WORKSPACE_SNAPSHOT_SIZE
|
||||
? workspaceSnapshot.blob
|
||||
: undefined
|
||||
);
|
||||
if (!result) {
|
||||
this.logger.warn(
|
||||
|
||||
Reference in New Issue
Block a user