(downloadConfig: DownloadFileConfigItem)
| 886 | }; |
| 887 | |
| 888 | const downloadFromUrl = async (downloadConfig: DownloadFileConfigItem) => { |
| 889 | if (!downloadConfig.url) throw new Error(t("TXT_CODE_f3031262")); |
| 890 | if (!downloadConfig.fileName) throw new Error(t("TXT_CODE_7b605ad8")); |
| 891 | |
| 892 | const targetPath = currentPath.value + downloadConfig.fileName; |
| 893 | if (fileStatus.value?.downloadTasks?.some((t) => t.path === targetPath)) |
| 894 | return reportErrorMsg(t("TXT_CODE_2bda9d65")); |
| 895 | |
| 896 | const { execute } = downloadFromUrlApi(); |
| 897 | const loadingDialog = await openLoadingDialog( |
| 898 | t("TXT_CODE_b3825da"), |
| 899 | t("TXT_CODE_2b5b8a3d"), |
| 900 | t("TXT_CODE_6f038f25") |
| 901 | ); |
| 902 | try { |
| 903 | await execute({ |
| 904 | params: { |
| 905 | uuid: instanceId || "", |
| 906 | daemonId: daemonId || "" |
| 907 | }, |
| 908 | data: { |
| 909 | url: downloadConfig.url, |
| 910 | file_name: targetPath |
| 911 | } |
| 912 | }); |
| 913 | message.success(t("TXT_CODE_c3a933d3")); |
| 914 | await getFileList(); |
| 915 | } catch (error: any) { |
| 916 | message.error(t("TXT_CODE_9ea5696b")); |
| 917 | reportErrorMsg(error.message); |
| 918 | } finally { |
| 919 | loadingDialog.cancel(); |
| 920 | } |
| 921 | }; |
| 922 | |
| 923 | const downloadFile = async (fileName: string) => { |
| 924 | const link = await getFileLink(fileName); |
nothing calls this directly
no test coverage detected