Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): unused blobs query (#10399)

Peng Xiao7e892b3a7ea7
diff --git a/packages/frontend/core/src/modules/blob-management/entity/unused-blobs.ts b/packages/frontend/core/src/modules/blob-management/entity/unused-blobs.ts
index 7e1fdf5225..c190e692d2 100644
--- a/packages/frontend/core/src/modules/blob-management/entity/unused-blobs.ts
+++ b/packages/frontend/core/src/modules/blob-management/entity/unused-blobs.ts
@@ -121,45 +121,26 @@ export class UnusedBlobs extends Entity {
}
private async getUsedBlobs(): Promise<string[]> {
- const batchSize = 100;
- let offset = 0;
- const unusedBlobKeys: string[] = [];
-
- while (true) {
- const result = await this.docsSearchService.indexer.blockIndex.aggregate(
- {
- type: 'boolean',
- occur: 'must',
- queries: [
- {
- type: 'exists',
- field: 'blob',
- },
- ],
- },
- 'blob',
- {
- pagination: {
- limit: batchSize,
- skip: offset,
+ const result = await this.docsSearchService.indexer.blockIndex.aggregate(
+ {
+ type: 'boolean',
+ occur: 'must',
+ queries: [
+ {
+ type: 'exists',
+ field: 'blob',
},
- }
- );
-
- if (!result.buckets.length) {
- break;
- }
-
- unusedBlobKeys.push(...result.buckets.map(bucket => bucket.key));
- offset += batchSize;
-
- // If we got less results than the batch size, we've reached the end
- if (result.buckets.length < batchSize) {
- break;
+ ],
+ },
+ 'blob',
+ {
+ pagination: {
+ limit: Number.MAX_SAFE_INTEGER,
+ },
}
- }
+ );
- return unusedBlobKeys;
+ return result.buckets.map(bucket => bucket.key);
}
async hydrateBlob(