(items)
| 584 | } |
| 585 | |
| 586 | function enqueueFiles(items) { |
| 587 | if (!Array.isArray(items) || !items.length) return; |
| 588 | |
| 589 | clearDropUploadError(); |
| 590 | let added = 0; |
| 591 | items.forEach((it) => { |
| 592 | const file = it.file; |
| 593 | if (!isFileLike(file)) return; |
| 594 | |
| 595 | const relativePath = sanitizeRelativePath( |
| 596 | preserveFolderStructure ? (it.relativePath || file.webkitRelativePath || file.name) : file.name, |
| 597 | file.name |
| 598 | ); |
| 599 | |
| 600 | const id = makeUploadId() + '_' + String(queue.length + 1); |
| 601 | const row = { |
| 602 | id, |
| 603 | file, |
| 604 | relativePath, |
| 605 | status: 'queued', |
| 606 | progress: 0 |
| 607 | }; |
| 608 | queue.push(row); |
| 609 | setItemStatus(row, 'queued', 0, tx('share_drop_status_queued', null, 'Queued')); |
| 610 | added += 1; |
| 611 | }); |
| 612 | |
| 613 | if (added === 0) { |
| 614 | const synthetic = { |
| 615 | id: makeUploadId() + '_invalid', |
| 616 | file: { name: 'upload', size: 0 }, |
| 617 | relativePath: tx('share_upload_selection_unavailable', null, 'Selection unavailable'), |
| 618 | status: 'error', |
| 619 | progress: 0 |
| 620 | }; |
| 621 | const errMsg = tx('share_upload_selection_read_error', null, 'Could not read selected file.'); |
| 622 | setItemStatus(synthetic, 'error', 0, errMsg); |
| 623 | showDropUploadError(errMsg, 0); |
| 624 | return; |
| 625 | } |
| 626 | |
| 627 | runQueue(); |
| 628 | } |
| 629 | |
| 630 | function filesFromInputList(list) { |
| 631 | return Array.from(list || []).map((file) => ({ |
no test coverage detected