1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 15:11:58 +00:00

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
This commit is contained in:
Alex 2024-11-22 16:38:20 -06:00 committed by GitHub
parent 1c82804f63
commit 6d492985a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,13 +96,25 @@
}); });
}; };
const readEntriesAsync = (reader: FileSystemDirectoryReader) => {
return new Promise<FileSystemEntry[]>((resolve, reject) => {
reader.readEntries(resolve, reject);
});
};
const getContentsFromFileSystemDirectoryEntry = async ( const getContentsFromFileSystemDirectoryEntry = async (
fileSystemDirectoryEntry: FileSystemDirectoryEntry, fileSystemDirectoryEntry: FileSystemDirectoryEntry,
): Promise<FileSystemEntry[]> => { ): Promise<FileSystemEntry[]> => {
return new Promise((resolve, reject) => {
const reader = fileSystemDirectoryEntry.createReader(); const reader = fileSystemDirectoryEntry.createReader();
reader.readEntries(resolve, reject); 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[]) => { const handleFiles = async (files?: FileList | File[]) => {