Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

batch delete requests

Inian491ed38cdce2
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.js
index ac72c56d196..9aaa6abf345 100644
--- a/studio/localStores/storageExplorer/StorageExplorerStore.js
+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js
@@ -804,13 +804,16 @@ class StorageExplorerStore {
this.clearSelectedItems()
- const batches = chunk(prefixes, BATCH_SIZE)
- await Promise.all(
- batches.map(
- async (batchedPrefixes) =>
- await this.supabaseClient.storage.from(this.selectedBucket.name).remove(batchedPrefixes)
- )
- )
+ // batch BATCH_SIZE prefixes per request
+ const batches = chunk(prefixes, BATCH_SIZE).map((batch) => () => {
+ return this.supabaseClient.storage.from(this.selectedBucket.name).remove(batch)
+ })
+
+ // make BATCH_SIZE requests at the same time
+ await chunk(batches, BATCH_SIZE).reduce(async (previousPromise, nextBatch) => {
+ await previousPromise
+ await Promise.all(nextBatch.map((batch) => batch()))
+ }, Promise.resolve())
// Clear file preview cache if deleted files exist in cache
const idsOfFilesDeleted = files.map((file) => file.id)