From 6d492985a261b5d63048cc3dca936f70be822487 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 22 Nov 2024 16:38:20 -0600 Subject: [PATCH] fix(web): cannot upload folder with more than 100 files (#14284) * fix: web cannot upload folder with more than 100 files * recursively call the function * async/do/while --- .../drag-and-drop-upload-overlay.svelte | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte b/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte index 620064ca1e..d0620de5b8 100644 --- a/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte +++ b/web/src/lib/components/shared-components/drag-and-drop-upload-overlay.svelte @@ -96,13 +96,25 @@ }); }; + const readEntriesAsync = (reader: FileSystemDirectoryReader) => { + return new Promise((resolve, reject) => { + reader.readEntries(resolve, reject); + }); + }; + const getContentsFromFileSystemDirectoryEntry = async ( fileSystemDirectoryEntry: FileSystemDirectoryEntry, ): Promise => { - return new Promise((resolve, reject) => { - const reader = fileSystemDirectoryEntry.createReader(); - reader.readEntries(resolve, reject); - }); + const reader = fileSystemDirectoryEntry.createReader(); + const files: FileSystemEntry[] = []; + let entries: FileSystemEntry[]; + + do { + entries = await readEntriesAsync(reader); + files.push(...entries); + } while (entries.length > 0); + + return files; }; const handleFiles = async (files?: FileList | File[]) => {