Skip to content

Commit

Permalink
Merge pull request #2113 from ProgrammeVitam/cp_7.0_bug_13501-read-al…
Browse files Browse the repository at this point in the history
…l-files-on-drag-drop

CP 7.0 - Bug #13501: Read all files when drag&drop instead of stopping at 100
  • Loading branch information
marob authored Oct 4, 2024
2 parents c8bc6c2 + 5aa5b44 commit 1472cdc
Showing 1 changed file with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,30 +237,18 @@ export class CollectUploadService {
}

private parseFileEntry(fileEntry: any): Promise<any> {
return new Promise((resolve, reject) => {
fileEntry.file(
(file: any) => {
resolve(file);
},
(err: any) => {
reject(err);
},
);
});
return new Promise((resolve, reject) => fileEntry.file(resolve, reject));
}

private parseDirectoryEntry(directoryEntry: any): Promise<any[]> {
private async parseDirectoryEntry(directoryEntry: any): Promise<any[]> {
const directoryReader = directoryEntry.createReader();
return new Promise((resolve, reject) => {
directoryReader.readEntries(
(entries: any) => {
resolve(entries);
},
(err: any) => {
reject(err);
},
);
});
const entries = [];
let batch;
// We have to call readEntries several times until it returns an empty list to make sure we read all entries (otherwise it is limited to 100 entries)
while ((batch = await new Promise<any[]>((resolve, reject) => directoryReader.readEntries(resolve, reject))).length) {
entries.push(...batch);
}
return entries;
}

private uploadInfo(uploadFile: CollectUploadFile) {
Expand Down

0 comments on commit 1472cdc

Please sign in to comment.