feat: introduce bulkDelete method for IFileProvider (#12614)

Fixes: FRMW-2974

Currently during the product imports, we create multiple chunks that must be deleted after the import has finished (either successfully or with an error). Deleting files one by one leads to multiple network calls and slows down everything.

The `bulkDelete` method deletes multiple files (with their fileKey) in one go
This commit is contained in:
Harminder Virk
2025-05-27 12:22:11 +05:30
committed by GitHub
parent 730cac0ed2
commit 791276e80f
8 changed files with 111 additions and 38 deletions

View File

@@ -81,11 +81,11 @@ export default class FileModuleService implements FileTypes.IFileModuleService {
async deleteFiles(id: string, sharedContext?: Context): Promise<void>
async deleteFiles(ids: string[] | string): Promise<void> {
const input = Array.isArray(ids) ? ids : [ids]
await Promise.all(
input.map((id) => this.fileProviderService_.delete({ fileKey: id }))
await this.fileProviderService_.delete(
input.map((id) => {
return { fileKey: id }
})
)
return
}
async retrieveFile(id: string): Promise<FileDTO> {

View File

@@ -40,7 +40,11 @@ export default class FileProviderService {
return this.fileProvider_.upload(file)
}
delete(fileData: FileTypes.ProviderDeleteFileDTO): Promise<void> {
delete(
fileData:
| FileTypes.ProviderDeleteFileDTO
| FileTypes.ProviderDeleteFileDTO[]
): Promise<void> {
return this.fileProvider_.delete(fileData)
}