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

This commit is contained in:
Peng Xiao
2025-02-25 10:58:43 +08:00
committed by GitHub
parent 848145150d
commit 7e892b3a7e

View File

@@ -121,11 +121,6 @@ export class UnusedBlobs extends Entity {
} }
private async getUsedBlobs(): Promise<string[]> { private async getUsedBlobs(): Promise<string[]> {
const batchSize = 100;
let offset = 0;
const unusedBlobKeys: string[] = [];
while (true) {
const result = await this.docsSearchService.indexer.blockIndex.aggregate( const result = await this.docsSearchService.indexer.blockIndex.aggregate(
{ {
type: 'boolean', type: 'boolean',
@@ -140,26 +135,12 @@ export class UnusedBlobs extends Entity {
'blob', 'blob',
{ {
pagination: { pagination: {
limit: batchSize, limit: Number.MAX_SAFE_INTEGER,
skip: offset,
}, },
} }
); );
if (!result.buckets.length) { return result.buckets.map(bucket => bucket.key);
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;
}
}
return unusedBlobKeys;
} }
async hydrateBlob( async hydrateBlob(