Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/impl/AzureBlobFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,9 @@ class AzureBlobFiles extends Files {
async _listFolder (filePath) {
const __listFolder = async (_filePath, /** @type {AzureProps} */azureProps) => {
const elements = []
const prefix = _filePath
// listBlobsFlat is using the '/' delimiter by default
// error handling (wrap)?
for await (const item of azureProps.containerClient.listBlobsFlat({ prefix })) {
const iterator = azureProps.containerClient.listBlobsFlat({ prefix: _filePath }).byPage({ maxPageSize: 1000 })
const response = (await iterator.next()).value
for (const item of response.segment.blobItems) {
elements.push({
name: item.name,
creationTime: item.properties.createdOn,
Expand Down
34 changes: 23 additions & 11 deletions test/impl/AzureBlobFiles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,19 @@ describe('_listFolder', () => {
azure.ContainerClient.mockImplementation(url => {
const containerMockList = url.includes('public') ? mockContainerPublicList : mockContainerPrivateList
return {
listBlobsFlat: containerMockList,
listBlobsFlat: () => {
return {
byPage: () => {
return {
next: () => {
return {
value: containerMockList()
}
}
}
}
}
},
getBlockBlobClient: () => ({
url: 'some/url?asdklk'
})
Expand All @@ -308,8 +320,16 @@ describe('_listFolder', () => {
async function testListFolder (filePath, listsPublic, listsPrivate, isRoot) {
const publicFiles = fakeFiles.map(f => publicDir + f)
const privateFiles = fakeFiles2.map(f => privateDir + f)
mockContainerPublicList.mockReturnValue(fakeAzureListResponse(publicFiles))
mockContainerPrivateList.mockReturnValue(fakeAzureListResponse(privateFiles))
mockContainerPublicList.mockReturnValue({
segment: {
blobItems: fakeAzureListResponse(publicFiles)
}
})
mockContainerPrivateList.mockReturnValue({
segment: {
blobItems: fakeAzureListResponse(privateFiles)
}
})

const fileList = await files._listFolder(filePath)
expect(fileList).toStrictEqual(expect.arrayContaining([expect.objectContaining({ name: expect.any(String) })]))
Expand All @@ -318,14 +338,6 @@ describe('_listFolder', () => {

expect(mockContainerPublicList).toHaveBeenCalledTimes(listsPublic ? 1 : 0)
expect(mockContainerPrivateList).toHaveBeenCalledTimes(listsPrivate ? 1 : 0)

if (listsPublic) {
expect(mockContainerPublicList).toHaveBeenCalledWith({ prefix: isRoot ? 'public' : filePath })
}

if (listsPrivate) {
expect(mockContainerPrivateList).toHaveBeenCalledWith({ prefix: filePath })
}
}

test('when it is the root (empty string)', async () => {
Expand Down