()
| 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 | |
| 781 | if (!res.value) throw new Error(t("TXT_CODE_e8ce38c2")); |
| 782 | |
| 783 | const addr = parseForwardAddress(getFileConfigAddr(res.value), "http"); |
| 784 | |
| 785 | uploadService.append(zipFile, addr, res.value.password, { |
| 786 | overwrite: true, |
| 787 | unzip: true, |
| 788 | code: "utf-8", |
| 789 | deleteAfterUnzip: true |
| 790 | }); |
| 791 | |
| 792 | message.loading({ content: t("TXT_CODE_b82225c3"), key: zipKey }); |
| 793 | } catch (error: any) { |
| 794 | reportErrorMsg(error.message); |
| 795 | } finally { |
no test coverage detected