The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Batch download selected files to improve durability
Joshen Limb73491739ce6
diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 2540d0aa5e1..124a3430b85 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -999,24 +999,44 @@ class StorageExplorerStore {this.ui.setNotification({id: toastId,category: 'success',- message: `Downloading folder "${folder.name}"`,+ message: `Successfully downloaded folder "${folder.name}"`,})}downloadSelectedFiles = async () => {+ let progress = 0const returnBlob = trueconst showIndividualToast = false- const toastId = toast.loading(`Downloading ${this.selectedItems.length} files...`, {- autoClose: false,- hideProgressBar: true,+ const toastId = this.ui.setNotification({+ category: 'loading',+ message: `Downloading ${this.selectedItems.length} files...`,})- const res = await Promise.all(- this.selectedItems.map(- async (item) => await this.downloadFile(item, showIndividualToast, returnBlob)- )- )- const uploadedFiles = res.filter(Boolean)+ const promises = this.selectedItems.map((file) => {+ return () => {+ return new Promise(async (resolve) => {+ const data = await this.downloadFile(file, showIndividualToast, returnBlob)+ progress = progress + 1 / this.selectedItems.length+ resolve(data)+ })+ }+ })++ const batchedPromises = chunk(promises, 10)+ const uploadedFiles = await batchedPromises.reduce(async (previousPromise, nextBatch) => {+ const previousResults = await previousPromise+ const batchResults = await Promise.allSettled(nextBatch.map((batch) => batch()))+ this.ui.setNotification({+ id: toastId,+ category: 'loading',+ message: `Downloading ${this.selectedItems.length} file${+ this.selectedItems.length > 1 ? 's' : ''+ }...`,+ description: STORAGE_PROGRESS_INFO_TEXT,+ progress: progress * 100,+ })+ return (previousResults ?? []).concat(batchResults.map((x) => x.value).filter(Boolean))+ }, Promise.resolve())const zipFileWriter = new BlobWriter('application/zip')const zipWriter = new ZipWriter(zipFileWriter, { bufferedWrite: true })@@ -1032,7 +1052,11 @@ class StorageExplorerStore {link.click()link.parentNode.removeChild(link)- toast.success(`Downloaded ${uploadedFiles.length} files`, { id: toastId })+ this.ui.setNotification({+ id: toastId,+ category: 'success',+ message: `Successfully downloaded ${uploadedFiles.length} files`,+ })}downloadFile = async (file, showToast = true, returnBlob = false) => {