Type s3 responses

This commit is contained in:
Adria Navarro 2023-01-17 10:27:45 +00:00
parent 343a19250b
commit eedc49de14
2 changed files with 6 additions and 6 deletions

View File

@ -361,8 +361,8 @@ export const deleteFolder = async (
Prefix: folder, Prefix: folder,
} }
let response: any = await client.listObjects(listParams).promise() const existingObjectsResponse = await client.listObjects(listParams).promise()
if (response.Contents.length === 0) { if (existingObjectsResponse.Contents?.length === 0) {
return return
} }
const deleteParams: any = { const deleteParams: any = {
@ -372,13 +372,13 @@ export const deleteFolder = async (
}, },
} }
response.Contents.forEach((content: any) => { existingObjectsResponse.Contents?.forEach((content: any) => {
deleteParams.Delete.Objects.push({ Key: content.Key }) deleteParams.Delete.Objects.push({ Key: content.Key })
}) })
response = await client.deleteObjects(deleteParams).promise() const deleteResponse = await client.deleteObjects(deleteParams).promise()
// can only empty 1000 items at once // can only empty 1000 items at once
if (response.Deleted.length === 1000) { if (deleteResponse.Deleted?.length === 1000) {
return deleteFolder(bucketName, folder) return deleteFolder(bucketName, folder)
} }
} }

View File

@ -34,7 +34,7 @@ module AwsMock {
// @ts-ignore // @ts-ignore
this.listObjects = jest.fn( this.listObjects = jest.fn(
response({ response({
Contents: {}, Contents: [],
}) })
) )