(
entryOrItems: FileSystemEntry | ScanItem[],
manualFolderName?: string
)
| 721 | }; |
| 722 | |
| 723 | const handleFolderUpload = async ( |
| 724 | entryOrItems: FileSystemEntry | ScanItem[], |
| 725 | manualFolderName?: string |
| 726 | ) => { |
| 727 | const isManual = Array.isArray(entryOrItems); |
| 728 | const folderName = isManual ? manualFolderName : (entryOrItems as FileSystemEntry).name; |
| 729 | |
| 730 | if (!folderName) return; |
| 731 | |
| 732 | const occupiedNames = await getExistingUploadNames( |
| 733 | [{ file: { name: folderName } as File, overwrite: false }], |
| 734 | currentPath.value |
| 735 | ); |
| 736 | const hasConflict = occupiedNames.has(folderName); |
| 737 | |
| 738 | const startUpload = async () => { |
| 739 | try { |
| 740 | spinning.value = true; |
| 741 | const zipKey = `zip_${folderName}`; |
| 742 | |
| 743 | message.loading({ |
| 744 | content: t("TXT_CODE_b3825da"), |
| 745 | key: zipKey |
| 746 | }); |
| 747 | |
| 748 | const allItems = isManual |
| 749 | ? (entryOrItems as ScanItem[]) |
| 750 | : await scanDirectory(entryOrItems as FileSystemEntry); |
| 751 | |
| 752 | const totalSize = allItems.reduce((sum, item) => sum + (item.file?.size || 0), 0); |
| 753 | // prevent files from being too large causing excessive memory usage in the browser |
| 754 | if (totalSize > MAX_FOLDER_SIZE) { |
| 755 | return message.error( |
| 756 | t("TXT_CODE_upload_folder_too_large", { |
| 757 | size: convertFileSize(MAX_FOLDER_SIZE.toString()) |
| 758 | }) |
| 759 | ); |
| 760 | } |
| 761 | |
| 762 | message.loading({ |
| 763 | content: t("TXT_CODE_ba027d6c"), |
| 764 | key: zipKey |
| 765 | }); |
| 766 | |
| 767 | const zipUint8 = await compressFolder(allItems); |
| 768 | const zipFileName = `upload_tmp_${folderName}_${Date.now()}.zip`; |
| 769 | const zipFile = new File([zipUint8 as any], zipFileName, { type: "application/zip" }); |
| 770 | |
| 771 | const { execute: getUploadMissionCfg } = uploadAddress(); |
| 772 | const res = await getUploadMissionCfg({ |
| 773 | params: { |
| 774 | upload_dir: currentPath.value, |
| 775 | daemonId: daemonId, |
| 776 | uuid: instanceId, |
| 777 | file_name: zipFileName |
| 778 | } |
| 779 | }); |
| 780 |
nothing calls this directly
no test coverage detected