From 9bbf4e1dc0aa175f737a372e39b20f8f7c0628a8 Mon Sep 17 00:00:00 2001 From: Marek Pietrzak Date: Wed, 29 Oct 2025 18:11:10 +0100 Subject: [PATCH] fix azure adapter listFiles ignoring numFiles --- src/AdapterAzureBlob.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/AdapterAzureBlob.ts b/src/AdapterAzureBlob.ts index 003a8a0..8e78fa2 100644 --- a/src/AdapterAzureBlob.ts +++ b/src/AdapterAzureBlob.ts @@ -277,12 +277,21 @@ export class AdapterAzureBlob extends AbstractAdapter { includeSnapshots: false, prefix, // Filter results by blob name prefix }; + let maxPageSize = 5000; + if (numFiles < maxPageSize) { + maxPageSize = numFiles; + } const files: [string, number][] = []; - const data = this._client.getContainerClient(name).listBlobsFlat(listOptions); - for await (const blob of data) { + for await (const blob of this._client + .getContainerClient(name) + .listBlobsFlat(listOptions) + .byPage({ maxPageSize })) { if (typeof blob.properties.contentLength !== "undefined") { files.push([blob.name, blob.properties.contentLength]); } + if (files.length >= numFiles) { + break; + } } return { value: files, error: null }; } catch (e) {